The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with csh script rahulrathod Shell Programming and Scripting 4 02-21-2008 09:38 AM
script problem tdavenpo Shell Programming and Scripting 3 01-04-2006 01:07 PM
Problem starting a script from a 'main'-script Rakker UNIX for Dummies Questions & Answers 3 06-28-2005 05:12 AM
problem with a script Lestat Shell Programming and Scripting 4 06-13-2005 09:30 AM
problem with ftp script...please help vancouver_joe UNIX for Advanced & Expert Users 2 11-22-2001 04:47 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-22-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Problem in Script !

#!/bin/ksh

cat queue.data | \
while read line
do

echo "$line"\c

done
----------------

In the above script , we are piping the output of cat command to \ and then
we are reading each line and doing something in loop.

Whats the objective or significance of using \ after | (pipe) ?

Please guide me in that !
Thanks in Advance.
Reply With Quote
Forum Sponsor
  #2  
Old 03-22-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Quote:
Originally Posted by varungupta
#!/bin/ksh

cat queue.data | \
while read line
do

echo "$line"\c

done
----------------

In the above script , we are piping the output of cat command to \ and then
we are reading each line and doing something in loop.

Whats the objective or significance of using \ after | (pipe) ?

Please guide me in that !
Thanks in Advance.
Single statements usually cannot be split across multiple lines, unless the line breaks are immediately preceded with a backslash
Reply With Quote
  #3  
Old 03-22-2007
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,030
it's a line continuation. this can be re-written as:
Code:
#!/bin/ksh

cat queue.data | while read line
do

echo "$line"\c

done
but you don't need a 'cat' here:
Code:
#!/bin/ksh
while read line
do
   echo "$line"\c
done < queue.data
Reply With Quote
  #4  
Old 03-22-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Thanks a lot friend !
Its been nice to get two things when asked one !
This shows knowledge increases when shared !
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0