![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| reversing order of lines in a file | gfhgfnhhn | Shell Programming and Scripting | 26 | 07-30-2009 09:01 AM |
| output string in reversing order | ccp | Shell Programming and Scripting | 3 | 11-19-2005 11:05 AM |
| sort a file in reverse order | frustrated1 | Shell Programming and Scripting | 11 | 09-21-2005 04:41 PM |
| look in file, seperate letters, put in order... | chekeitout | UNIX for Advanced & Expert Users | 3 | 11-05-2004 05:00 PM |
| Sorting filenames by order in another file | samudimu | UNIX for Advanced & Expert Users | 4 | 05-24-2002 01:03 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Reversing file order using SED
Im trying to develop a shell script that will change the content order of the file.
For example I have a file that says a b c d I want to change this to be d c b a Im trying to use sed to this by reading the file and then inserting each line at the top #!/usr/bin/ksh PATCHFILE=patch_order REVERSE=reverse_ REVERSEPATCHFILE=$REVERSE$PATCHFILE TMP=.TMP rm $REVERSEPATCHFILE$TMP echo got here while read PATCHNAME; do sed -e "1i\\ $PATCHNAME" >$REVERSEPATCHFILE$TMP #mv $REVERSEPATCHFILE$TMP $REVERSEPATCHFILE done <$PATCHFILE The problem is it just puts the lines in exactly the same order. Am i missing something? |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|