2

I would like to delete the first 40 lines of a good number of ASCII files and save the ASCII files without those 40 lines

I'm working under OSX High Sierra, realized that the -i option in sed was not working unless I create a backup file, so I tried using this command:

sed -i'backup' -e '1,40d' *.txt

It however only modifies and deletes the first 40 lines in my first file (alphabetically), but not the others.

How can I edit multiple files with just one command?

Thanks

Tiw
  • 5,078
  • 13
  • 24
  • 33
Guillaume
  • 23
  • 2

1 Answers1

0

You can use the following command that will

  • look in the current folder
  • ignore sub folder
  • take only into account files whose filenames end with '*.txt'
  • before executing the sed command.

Command:

   find . -maxdepth 1 -type f -name '*.txt' -exec sed -i 'backup' -e '1,40d' {} \;
Allan
  • 11,650
  • 3
  • 27
  • 49