The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Or operator with if babom HP-UX 1 10-03-2007 03:56 PM
Bit shift operator naan High Level Programming 5 09-08-2006 02:13 AM
And operator rcarnesiii Shell Programming and Scripting 4 08-04-2005 02:04 AM
Problem about c++ new operator xbjxbj High Level Programming 3 04-27-2005 05:17 AM
Operator question TheCrunge UNIX for Dummies Questions & Answers 5 03-01-2005 03:27 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-07-2008
satyam_sat satyam_sat is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 20
Smile Help need: new line operator :

We are calling Unix through SQR.
I want to know there is any operator available in Unix ...so that the remaining command should go to the next line
I will explain , find the below code . It is in single line which is coded as single variable in SQR and called using 'call system using ' command.....now i want 'the operator or command" which will devide the code and print like Step 2.(actually i want to use that command before 'if ' below ....)

Step1 : (single Line)

awk '{gsub(/^\|| +\|/,"") if(NF!=10){for(i=1;i<=(10-NF);i++)printf("%s|",k[i]);print;next}{for(i=1;i<=3;i++)k[i]=$i}print}' FS='|' file


Step 2: ( two lines ....2 nd start with 'if' )

awk '{gsub(/^\|| +\|/,"")
if(NF!=10){for(i=1;i<=(10-NF);i++)printf("%s|",k[i]);print;next}{for(i=1;i<=3;i++)k[i]=$i}print}' FS='|' file
  #2 (permalink)  
Old 04-07-2008
jgt jgt is online now
Registered User
  
 

Join Date: Apr 2007
Location: 44.21.48N 80.50.15W
Posts: 445
End the first line with a \
  #3 (permalink)  
Old 04-07-2008
satyam_sat satyam_sat is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 20
Error coming :

awk '{gsub(/^\|| +\|/,"") a\ if(NF!=6){for(i=1;i<=(6-NF);i++)printf("%s|",k[i]);print;next}{for(i=1;i<=3;i++)k[i]=$i}print}' FS='|' key.txt

awk: cmd. line:1: {gsub(/^\|| +\|/,"") a\ if(NF!=6){for(i=1;i<=(6-NF);i++)printf("%s|",k[i]);print;next}{for(i=1;i<=3;i++)k[i]=$i}print}
awk: cmd. line:1: ^ backslash not last character on line



The above error is coming .......
I think u understood the requirement .....we have to use the operator so that from 'if' to till the end ...sholud be treated as new line.

I dont know why error is coming even if the entire code is on single line ...
  #4 (permalink)  
Old 04-07-2008
ag79 ag79 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 33
what exactly is the problem here?

If you want all of it on a single line, end the gsub func call with a semicolon (, before the if.. starts.

You need to use the backslash as the last character of the line if you need to spread the awk string across more than one lines.

maybe i didnt understand what is your issue, can you elaborate?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0