I have a folder that has 2800 .txt files in it and I need to delete the first line of every files. The names of the files are all different except for that fact that they end with .txt .
would it be possible to do that while keeping the same file name (instead of sending the output (file without the first line) to another file)...
something like this does the trick
sed -i '1d' *.txt
where -i is inplace editing
edit: adition
pls try also this
time sed -i '1d' *.txt
and compare with other solutions (just add time before)[trying certainly with some backup files]
You could do a bash script. Something like this:
#!/bin/bash
for filename in *;
do
tail -n +2 "${filename}"
done
The run it from command line: $ <script_file.sh>
Take this with a grain of salt. I'm not actually running on a *nix machine. See here for a variety of ways of deleting the first line of a file. Also note that tail
is supposed to be much faster than sed
, if performance is important to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With