Help needed in 'awk' : pls.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in 'awk' : pls.
# 1  
Old 04-05-2008
Help needed in 'awk' : pls.

we have a file File1.I have used the below code to append 'file1' to each row.it is appending 'file1' but there is 5 empty space is coming after the end of each row.i found this opening in 'vi' mode and moving the cursor on each row ...can u help me ...


File1:
E100|0|05/29/1993|0|E001|E000
E102|0|01/23/1994|0|E001|E003
E104|0|06/04/1994|0|E001|E003
E105|0|07/30/1993|0|F001|E003
E106|0|01/09/1993|0|E001|E003


awk '{print "file1|"$1,$2,$3,$4,$5,$6}' File1 > result

result:

file1|E100|0|05/29/1993|0|E001|E000____
file1|E102|0|01/23/1994|0|E001|E003
file1|E104|0|06/04/1994|0|E001|E003
file1|E105|0|07/30/1993|0|F001|E003
file1|E106|0|01/09/1993|0|E001|E003
# 2  
Old 04-05-2008
This should work for you.
Code:
awk '{print "file1|"$0}' File1 > result

# 3  
Old 04-05-2008
Hi
I must pass column variables in to awk command to print in desired order and desired number of columns.File which i have given is sample example
iam printing only few columns of actual file .....

Please help me ..........
# 4  
Old 04-05-2008
Code:
awk -F\| '{print "file1|"$1,$2,$3,$4,$5,$6}' File1 > result

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

use awk to edit a file..pls help

hey i want to over write the fourth field of a ':' delimited file by first finding the required row by using grep. i have done the following cat file | grep no. | awk -F ':' { $4=count; print $1:$2:$3:$4;} the correct values are being printed but nothin is bein added to the file..please... (5 Replies)
Discussion started by: dhe.arora
5 Replies

2. Shell Programming and Scripting

Menu driven Script needed ..pls help

Hi Guys.. am new to unix scrpiting..I need a Menu need to create using shell scrpting eg: Food items ready paid if i press "f" need to add items for a file food items.. if i press "r" it need to move into ready and remove from food items if i press "p" need to update a filed in... (1 Reply)
Discussion started by: sasdua
1 Replies

3. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

4. Solaris

executing cgi programs in solaris(B89) needed urgent help,pls!

Hi all, I am trying to execute cgi scripts on solaris, but everytime i get a internal server error... The syntax of my .cgi script is correct as ive checked.. Steps i followed 1.started apache 2.The UNIX and Linux Forums - Learn UNIX and Linux from Experts (in opera) 3.places my cgi scripts... (7 Replies)
Discussion started by: wrapster
7 Replies

5. Shell Programming and Scripting

AWK - HELP pls explain this ?

echo "23.54" | awk ' function round(A) { return int( A + 0.5 ) } { printf("%d\n",round($1)); }'> > > > > > awk: syntax error near line 2 awk: bailing out near line 2 (2 Replies)
Discussion started by: santosh1234
2 Replies

6. Solaris

how to install xen on solaris?, urgent help needed, pls

Hi , I wanted to know how to install XEN on solaris? I have looked at virutal box but the latest release is not supporting many OS, and for my development work i need some sort of virtual systems..... and older versions of virtual box dont run on my build of solaris (b83)!!! so please help ... (3 Replies)
Discussion started by: wrapster
3 Replies

7. UNIX for Advanced & Expert Users

urgent help needed!!in copying files to /tmp at boot time,pls help!

Hi all, I am trying to boot a an OS from RAM...(its a opensolaris based distro) For this i have picked up 2 key lib files that when copied to /tmp and mounted to respective places will do the job.. The sizes of these files combined comes upto 600mb.(i have 2gb ram) Now i have also located the... (0 Replies)
Discussion started by: wrapster
0 Replies

8. Shell Programming and Scripting

unable to log into gdm, urgent help needed!!!pls

Hi all, I was playing around with some scripts and spoilt solaris completely .. So i reinstalled and thought of giving the password once i log in... However i forgot all about it and went ahead installing all my drivers and particularly KDE 3.5.8 on my system.. But for kde to show up at the... (0 Replies)
Discussion started by: wrapster
0 Replies

9. AIX

pass through printing help needed pls

Hi from a newbie We have set up 2 new IBM servers with AIX5.3 We have 3 Zebra printers with static IP adresses on their own print servers. I have set the up ok on the system using generic drivers, Zebra do not have a compatible driver for AIX. We are printing barcodes on these printers.... (2 Replies)
Discussion started by: RickP
2 Replies

10. Shell Programming and Scripting

2D Array using AWK - pls help

Hi, i want to write a script using AWK to compare the difference between 2 text file using 2 dimensional array. The script should compare each and every symbol display in the 5 by 5 matrix. The output should display the coordinates (x,y) of where the difference lies, and displays what is the... (8 Replies)
Discussion started by: Raynon
8 Replies
Login or Register to Ask a Question