Geeks Talk

Prepare for your Next Interview




Korn shell question

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?...


Go Back   Geeks Talk > Operating Systems > Unix/Linux

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-01-2008
Junior Member
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
hasski is on a distinguished road
Korn shell question

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

What will the above do?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-29-2008
Junior Member
 
Join Date: Sep 2007
Location: Bangalore
Posts: 13
Thanks: 1
Thanked 1 Time in 1 Post
Divya.B.V is on a distinguished road
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.
Reply With Quote
  #3 (permalink)  
Old 06-01-2008
Junior Member
 
Join Date: Jun 2008
Location: hyd
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
srinivm is on a distinguished road
Re: Korn shell question

any one can guide me for writing a shell script for to print the given string in a reverse order
Reply With Quote
  #4 (permalink)  
Old 06-01-2008
Junior Member
 
Join Date: Jun 2008
Location: hyd
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
srinivm is on a distinguished road
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.
Reply With Quote
  #5 (permalink)  
Old 06-18-2008
Junior Member
 
Join Date: May 2008
Location: chennai
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
abusaud is on a distinguished road
Re: Korn shell question

pls divya....can u teach me how to write these typr of scripts
Reply With Quote
  #6 (permalink)  
Old 07-26-2008
Junior Member
 
Join Date: Jul 2008
Location: india
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
vishalcjha is on a distinguished road
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
Reply With Quote
Reply

  Geeks Talk > Operating Systems > Unix/Linux


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 05:55 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved