0

File list contains a few thousands filenames like:

./folder/folder/file.ext

For each item of the list I should edit a file: substitute text pattern "old_text_pattern" by "new_text_pattern". This command:

cat filelist | while read line; do sed -i 's/END_CREDIT_END/END_CREDIT/g' "$line"; done

gives an error:

sed: 1: "./folder ...": invalid command code . 

How to perform the substitution properly? Thanks.

hdf
  • 155
  • 3
  • 11

1 Answers1

1

OS X sed -i is not like GNU sed -i. OS X's requires an argument.

cat filelist | while IFS= read -r line
  do sed -i bak 's/END_CREDIT_END/END_CREDIT/g' "$line"
done
that other guy
  • 116,971
  • 11
  • 170
  • 194