0

I wish to remove all caret characters from all files present in the current directory. Please help.

Sushrut Kanetkar
  • 363
  • 3
  • 13
  • 3
    1) This way, sed operates on stdin and writes to stdout. To edit files and save back, you need the `-i` flag as well as the file name, which, inside a `find -exec` command, you can get with `{}`. 2) Your command will not simply remove carets, but replace them by commas. – Siguza Apr 01 '17 at 21:40
  • you may want to add `maxdepth` as well. – karakfa Apr 01 '17 at 21:44
  • No, that won't work -- it'll do nothing yet it'll never end. – agc Apr 01 '17 at 21:47
  • Can anyone give me an example ? – Sushrut Kanetkar Apr 01 '17 at 22:27

1 Answers1

2

You must tell sed to edit the file in place by specifying the the -i option, otherwise sed will write to its stdout. You're not passing any file names to sed. Use {} syntax of find to pass matched file names.

find . -type f -exec sed -i 's/\^//g' {} +

Please note that to replace matched patterns with nothing, you must leave the replace part of the substitution empty.

oguz ismail
  • 1
  • 16
  • 47
  • 69
ziggurat
  • 92
  • 7