- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- concatenate multiple files skipping the first 20 l...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2009 12:15 PM
тАО03-22-2009 12:15 PM
I have to concatenate multiple (500) text files with different number of rows, but skipping the first 20 rows/lines in each file.
I would be very grateful for any suggestions.
Thank you,
Cristian
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2009 12:26 PM
тАО03-22-2009 12:26 PM
Re: concatenate multiple files skipping the first 20 lines in each file
for file in $(< file-list); do
tail -n +19 $file
done > new-file
(You need to use ls to get the files, you can replace $() by something like $(ls *.txt).)
If 500 is too big:
while read file; do
tail -n +19 $file
done < file-list > new-file
- Tags:
- tail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2009 01:00 PM
тАО03-22-2009 01:00 PM
SolutionOne way is:
# cat ./mycat
#!/usr/bin/perl
use strict;
use warnings;
my $OLDARGV = '';
my $lines = 0;
while (<>) {
if ( $OLDARGV ne $ARGV ) {
$OLDARGV = $ARGV;
$lines = 0;
}
$lines++;
next unless $lines > 20;
close ARGV if eof;
print;
}
...run as :
# ./mycat file1 file2 file3... > file.out
Regards!
...JRF...
# ./
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2009 02:36 AM
тАО03-23-2009 02:36 AM
Re: concatenate multiple files skipping the first 20 lines in each file
Yours,
Cristian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2009 02:41 AM
тАО03-23-2009 02:41 AM
Re: concatenate multiple files skipping the first 20 lines in each file
Also it seems that there is a trim (trim 1.0 version is the latest) package for linux that will remove the first lines from the files and then, cat will do the job.
Cheers,
Cristian