Prepare for your Next Interview
This is a discussion on Korn shell question within the Unix/Linux forums, part of the Operating Systems category; cat $filename | sed 's/^Hello//' if [$? -ne 0] then print "error" What will the above do?...
|
|||
|
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. ![]() |
|
|||
|
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. |
|
|||
|
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 |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| shell script | Barbie | Unix/Linux | 10 | 1 Week Ago 02:49 AM |
| what is shell? | srinu.tenali | Unix/Linux | 2 | 12-25-2007 02:22 AM |
| what is shell? | srinu.tenali | Unix/Linux | 4 | 12-25-2007 02:00 AM |
| Aston Shell is a powerful, fast, stable and flexible shell replacement application. | JobHelper | Geeks Lounge | 0 | 09-21-2007 03:11 AM |
| Shell Script | henri084 | Unix/Linux | 1 | 05-31-2007 04:32 AM |