views:

567

answers:

5
+3  Q: 

Delete First Line

I need a cmd script that deletes the first line in my text file. the scenario is the following: I take a txt file from FTP everyday, the problem is that it comes with blank line at the top then the headers of the file.. Since I'm importing that file automatically into an access table, that blank line is causing me problems..

So I urgently need a script that deletes the blank line and saves the file..

+5  A: 

You didn't specify a platform. Here's how to do it in any *NIX environment (and Windows+Cygwin):

sed -i~ 1d target-file
Adam Rosenfield
Windows 2000 platform
+3  A: 

To remove the first line, I would use

tail -n +2 source-file > target-file

If you want this on Windows, download the gnu utils to obtain a tail command. +2 means "Start at the second line".

Renze de Waal
If the source and target files are the same (which is likely), this clobbers that file.
Adam Rosenfield
You're right they should not be the same. However, they can be chosen by whoever writes the script.
Renze de Waal
+8  A: 

Windows/command prompt:

more +1 filename.ext > otherfilename.ext
Guido Domenici
very nice! Much better than my answer!
Preet Sangha
+1: Nice to see that Microsoft has improved the more command. I had noticed that other commands where improved a lot, but missed this one.
Renze de Waal
A: 

In windows without extra tools:

findstr /V /R "^$" filename.whatever

No extra tools needed

Preet Sangha
A: 

Thanks Guido, used your command and worked just fine :)