-
Junior Member
Korn shell question
cat $filename | sed 's/^Hello//'
if [$? -ne 0] then print "error"
What will the above do?
-
Junior Member
Re: Korn shell question
Hi,
cat $filename | sed 's/^Hello//'
The above code displays the filename, which acts as input to sed. This sed here searches for the occurance of the word Hello at the beggining (^ ->this specifies beggining) and removes it.
if [$? -ne 0] then print "error"
Here $? 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.
-
Junior Member
Re: Korn shell question
any one can guide me for writing a shell script for to print the given string in a reverse order
-
Junior Member
Re: Korn shell question
any one can guide me for writing a shell script for to find the number of times a particular char repeats in a string
Last edited by srinivm; 06-01-2008 at 12:28 AM.
-
Contributing Member
Re: Korn shell question
pls divya....can u teach me how to write these typr of scripts
-
Junior Member
Re: Korn shell question
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules