Showing posts with label echo command in linux shell scripting. Show all posts
Showing posts with label echo command in linux shell scripting. Show all posts

Saturday, May 19, 2012

Echo command

The Echo command is also used for checking whether the previous command is executed correctly or not.

root@tester ~]# touch test.txt
[root@tester ~]# echo $?
0
It display zero when it is executed correctly, If the command is not correctly executed it will show some numbers like below.

[root@tester ~]# tuch test1.txt
-bash: tuch: command not found
[root@tester ~]# echo $?
127

Echo command is also used to check the current working shell of the users.

[root@tester ~]# echo $SHELL
/bin/bash

echo *? to know the numbe of arguments passed.

You can also check the version with the below command.

[root@tester ~]# /bin/bash --version
GNU bash, version 3.00.15(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.