![]() |
|
|
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 |
| make multiple line containing a pattern into single line | VTAWKVT | Shell Programming and Scripting | 13 | 12-04-2008 06:40 PM |
| Adding Multiple Lines to Multiple Files | dayinthelife | Shell Programming and Scripting | 2 | 06-04-2008 12:50 PM |
| Ksh Storing Multiple Files and reading each line in each file. | developncode | UNIX for Dummies Questions & Answers | 1 | 04-08-2008 05:44 PM |
| Command line tool to join multiple .wmv files? | karman | OS X (Apple) | 2 | 09-23-2007 02:52 AM |
| Cat'ing a multiple line file to one line | djsal | Shell Programming and Scripting | 1 | 04-16-2007 09:50 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to Eliminate first line of multiple files
hi gurus ,,
I have multiple files with same file pattern..in a particular directory for ex: file20061101.trf file20061102.trf file20061103.trf Each of the file has a header as column names.. My questions is how can i eliminate the first row of each of these files and write it into a single file.. Can anyone help uup with a shell script.. i was thinking of looping each file and get the count and then do tail of -1 to a file.. but was not sure whether its the best method..if anyone had come across the situation please let me know Appreciate any kind of information or help Thanks n Regards Sish |
|
||||
|
Much easier with pipes than perl: Code:
# Print a list of files with 'find', feed it into while loop.
# For each filename, open file, read and discard first line,
# print rest of file, while redirecting all output into 'output'
find ./ -iname 'file2006*' |
while read FILE
do
( read LINE ; cat ) < "${FILE}"
done > output
|
|
|||||
|
Any reason that you can't use good old tail? It has a '+' option that you can use to print lines from that line onward: Code:
# cat test.sh #!/bin/ksh echo $1 echo $? #tail +2 test.sh echo $1 echo $? Run tail +2 on each file through the while loop. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|