LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   a little bash help: cat multiple files together except first line? (https://www.linuxquestions.org/questions/linux-general-1/a-little-bash-help-cat-multiple-files-together-except-first-line-788049/)

sanimfj 02-09-2010 01:10 PM

a little bash help: cat multiple files together except first line?
 
Hopefully the title summarized what I need help with. I have multiple files that I would like to concatenate in bash.

ie:

cat file1 file2 file3 > bigfile

except I do not want to include the first line from each file (). Any help? Thanks.

TB0ne 02-09-2010 01:18 PM

Quote:

Originally Posted by sanimfj (Post 3858089)
Hopefully the title summarized what I need help with. I have multiple files that I would like to concatenate in bash.

ie:

cat file1 file2 file3 > bigfile

except I do not want to include the first line from each file (). Any help? Thanks.

We'll be glad to help...post what you've written and tried so far. If you need a hint, I'd start by running the individual files through sed, and stripping the first line off there. A simple bash loop can go through all the files in a directory, strip the line, and add it to the output file.

tuxdev 02-09-2010 04:11 PM

Code:

cat <(tail +2 file1) <(tail +2 file2) <(tail +2 file3) > bigfile
Not really the most efficient method, but it does get it done.

colucix 02-09-2010 04:27 PM

Code:

awk 'FNR > 1' file? > bigfile


All times are GMT -5. The time now is 08:35 PM.