Results 1 to 6 of 6

Thread: Korn shell question

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Answers
    1

    Korn shell question

    cat $filename | sed 's/^Hello//'
    if [$? -ne 0] then print "error"

    What will the above do?


  2. #2
    Junior Member
    Join Date
    Sep 2007
    Answers
    13

    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.


  3. #3
    Junior Member
    Join Date
    Jun 2008
    Answers
    2

    Re: Korn shell question

    any one can guide me for writing a shell script for to print the given string in a reverse order


  4. #4
    Junior Member
    Join Date
    Jun 2008
    Answers
    2

    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.

  5. #5
    Contributing Member
    Join Date
    May 2008
    Answers
    30

    Re: Korn shell question

    pls divya....can u teach me how to write these typr of scripts


  6. #6
    Junior Member
    Join Date
    Jul 2008
    Answers
    6

    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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact