![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to merge these two files? | fedora | Shell Programming and Scripting | 3 | 02-12-2008 06:45 PM |
| merge files | koti_rama | Shell Programming and Scripting | 5 | 12-24-2007 10:59 PM |
| How to merge files | lestat_ecuador | Shell Programming and Scripting | 3 | 06-07-2007 06:45 AM |
| help in merge files | u263066 | Shell Programming and Scripting | 5 | 07-24-2006 03:24 AM |
| Using NAWK to merge two files | madhunk | Shell Programming and Scripting | 7 | 06-07-2006 10:27 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
use of sed over cat to merge files
I have three files, basically:
file 1 - one line header file 2 - big data (approx 80GB) file 3 - a one line trailer the existing process cats these together i.e cat file 1 file 2 file 3 however... I was thinking, surely it could be more efficient to insert the header (file 1) on the data file (file 2) and then just append the trailer (file 3) on the end. I wondered if this could be achieved some way via sed instead, i.e. something like: #!/bin/sh export HEAD=`cat $1` export TRAIL=`cat $3` sed -e '1i\ $HEAD $a\ $TRAIL' $2 > complete_file.txt ...but it seems this won't substitute in the variable values setup within the shell script already Thanks in advance for any replies on this one. Last edited by miwinter; 11-28-2007 at 01:24 PM.. |
|
||||
|
I agree that there's little you can do about making a 80GB edit more efficient.
The reason your "sed" command did not work is because you used single-quotes around the expression, which prevents the variables from being evaluated: Code:
# i=100 # echo "$i" 100 # echo '$i' $i |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|