LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-09-2010, 01:10 PM   #1
sanimfj
LQ Newbie
 
Registered: Dec 2009
Posts: 7

Rep: Reputation: 0
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.
 
Old 02-09-2010, 01:18 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,473

Rep: Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540
Quote:
Originally Posted by sanimfj View Post
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.
 
Old 02-09-2010, 04:11 PM   #3
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 111Reputation: 111
Code:
cat <(tail +2 file1) <(tail +2 file2) <(tail +2 file3) > bigfile
Not really the most efficient method, but it does get it done.
 
Old 02-09-2010, 04:27 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,490

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Code:
awk 'FNR > 1' file? > bigfile
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH: read every line in the files and use the line as parameters as another program tam3c36 Programming 10 12-07-2010 01:42 PM
How to Cat multiple files with numeric differences zxcvcxz Linux - Software 7 11-19-2009 06:49 PM
[SOLVED] basic bash help (for, cat, grep): cross reference matching between files NoWone Linux - Newbie 3 10-18-2009 09:11 AM
Search values within multiple files line to line Chrizzieej Programming 5 09-26-2008 04:11 PM
logrotate log files - keeping in order when using grep or cat and bash dmellem Linux - Software 6 02-11-2005 01:05 PM


All times are GMT -5. The time now is 11:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration