cat $filename | sed 's/^Hello//'
if [$? -ne 0] then print "error"
What will the above do?
Printable View
cat $filename | sed 's/^Hello//'
if [$? -ne 0] then print "error"
What will the above do?
Hi,
[B]cat $filename | sed 's/^Hello//'[/B]
The above code displays the filename, which acts as input to sed. This sed here searches for the occurance of the word [B]Hello[/B] at the beggining (^ ->this specifies beggining) and removes it.
[B]if [$? -ne 0] then print "error"[/B]
Here [B]$?[/B] is nothing but the return value. After executing any command, some check for errors. If it returns zero, then no error else it means there was some error executing the previous command.
I hope its clear for you. :)
any one can guide me for writing a shell script for to print the given string in a reverse order
any one can guide me for writing a shell script for to find the number of times a particular char repeats in a string
pls divya....can u teach me how to write these typr of scripts
i m not in front of my unix server so can not give exact answer
but to find occurance of character in string u can try following:
no_of_occurance=`expr "string" : 'char_name'`
i think this should work