Solved

removing top 3 lines from multiple files

Posted on 2013-10-27
2
176 Views
Last Modified: 2013-10-28
Hi
I need piece of code to process files
I have multiple files bew_to_kc*.csv  like    bew_to_kc_1.csv,bew_to_kc_2.csv,bew_to_kc_a.csv  etc  , I need to remove top 3 lines from these files and write to temp files named bew_to_kc*.temp files like bew_to_kc_1.temp,bew_to_kc_2.temp,bew_to_kc_a.temp . The number of files could change

thanks for you help

thanks
uco
0
Comment
Question by:uco
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
#!/bin/bash
for f in bew_to_kc*.csv  ; do tail +4 $f > ${f%.csv}.temp ; done
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
Along the lines of ozo

#!/bin/bash
for file in bew_to_kc*.csv
do
   sed 1,3d $file >${file%.csv}.temp
done

Open in new window

0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now