![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to reverse the contents of a file? | aajan | UNIX for Advanced & Expert Users | 10 | 05-17-2008 08:03 AM |
| how to arrange 3 file to one using awk...? | penyu | Shell Programming and Scripting | 9 | 01-17-2008 02:26 AM |
| Need to read a file in reverse | scorreg | Shell Programming and Scripting | 5 | 03-01-2006 09:14 PM |
| sort a file in reverse order | frustrated1 | Shell Programming and Scripting | 11 | 09-21-2005 12:41 PM |
| reverse lookup file problem | Westy564 | IP Networking | 2 | 01-09-2004 11:55 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Reverse Arrange File
I've got hundreds of lines in a file that looks like this:
Line1 CCR CCH Line2 ICVM FBO GSC Line3 MKF The result should be like the one below so that I can insert them on our database. Line1 CCR Line1 CCH Line2 ICVM Line2 FBO Line2 GSC Line3 MKF Thanks in advance! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
nawk '{ for(i=2;i<=NF;i++) print $1, $i }' myFile
|
|
#3
|
|||
|
|||
|
do something like the following to get just the list of words
Code:
cat input-file | while read N
do
for d in $N
do
echo $d
done
done
|
|
#4
|
|||
|
|||
|
Quote:
Code:
awk '{ for(i=2;i<=NF;i++) print $1, $i }' myFile
|
|
#5
|
|||
|
|||
|
nawk is the "usable" version of awk on Solaris, vgersh works on Solaris I believe. awk on Solaris is an ancient version and does play well with everyone else's awk.
|
|||
| Google The UNIX and Linux Forums |