Skip to content

Instantly share code, notes, and snippets.

@ctrueden
Created March 29, 2012 15:56
Show Gist options
  • Select an option

  • Save ctrueden/2238895 to your computer and use it in GitHub Desktop.

Select an option

Save ctrueden/2238895 to your computer and use it in GitHub Desktop.
I am an idiot who deserves public shame
: curtis@sirius ~/code/ImageJ/imglib (master)
find . -exec sed -i '' -e 's/^M//' {} \;
sed: .: in-place editing only works for regular files
sed: ./.git: in-place editing only works for regular files
sed: ./.git/hooks: in-place editing only works for regular files
sed: ./.git/info: in-place editing only works for regular files
sed: ./.git/logs: in-place editing only works for regular files
sed: ./.git/logs/refs: in-place editing only works for regular files
sed: ./.git/logs/refs/heads: in-place editing only works for regular files
sed: ./.git/logs/refs/remotes: in-place editing only works for regular files
sed: ./.git/logs/refs/remotes/fiji: in-place editing only works for regular files
sed: ./.git/logs/refs/remotes/github: in-place editing only works for regular files
sed: ./.git/logs/refs/remotes/origin: in-place editing only works for regular files
sed: ./.git/logs/refs/remotes/pacific: in-place editing only works for regular files
sed: ./.git/objects: in-place editing only works for regular files
sed: ./.git/objects/00: in-place editing only works for regular files
sed: ./.git/objects/01: in-place editing only works for regular files
sed: ./.git/objects/02: in-place editing only works for regular files
sed: ./.git/objects/03: in-place editing only works for regular files
sed: ./.git/objects/04: in-place editing only works for regular files
sed: ./.git/objects/05: in-place editing only works for regular files
sed: ./.git/objects/06: in-place editing only works for regular files
sed: ./.git/objects/07: in-place editing only works for regular files
sed: ./.git/objects/08: in-place editing only works for regular files
^C
: curtis@sirius ~/code/ImageJ/imglib (master)
git status
error: bad index file sha1 signature
fatal: index file corrupt
@MissValeska
Copy link
Copy Markdown

I am confused, What is wrong with this?

@MichaelCurrin
Copy link
Copy Markdown

So doing sed on .git accidentally will break that local git repo it looks like.

@ctrueden
Copy link
Copy Markdown
Author

ctrueden commented May 23, 2020

Yep. When shell scripting, make sure you only loop over the files you intend! One way here would have been find * instead of find ., since the * glob does not match files starting with .. (And sorry @MissValeska for the six-year delay in reply—I didn't notice your earlier comment till @MichaelCurrin's comment just now!)

@MichaelCurrin
Copy link
Copy Markdown

Okay thanks I'll add to my notes.

Btw the in place editing regular files error is the reason I got here. I know now to use sed on files only using find -type f

@MichaelCurrin
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment