Stupid script kiddies. Respect the OS you’re writing for.

for file in `find -name “*.php”`; do cp $file $file.orig; cat $file.orig | tr -d “^M” > $file; echo $file; done;

10 Responses to “Stupid script kiddies. Respect the OS you’re writing for.”

  1. sabrewing says:

    10 HOME
    20 PRINT “Hi, Bennie!”
    30 PRINT “Wow, you’re doing scripting stuff? Really cool.”
    40 PRINT “Don’t you miss the old days of BASIC and LOGO? I certainly do. The little tutorials that came with my Apple ][c were awesome.”
    50 PRINT “Well, catchu later, tigerbutt!”
    RUN

  2. strredwolf says:

    If only they installed Emacs…

  3. doco says:

    This makes my brain hurt. O.o

  4. Phil says:

    Something tells me from the mistake made that they develop out in windows-land.

  5. Phil says:

    LOGO was the very first language I ever programmed in 🙂 I would have been, umm ….. 8 or 9?

  6. Phil says:

    Yeah. Shell commands can be kinda weird. But they are so nice and powerful 🙂

  7. pholph says:

    Mad love for bash scripts…

    Yeah, being able to hack out a line in a bash shell, that does what a project manager suggests will take -days- to do. Shows the mind numbing power of a CLI and language.

    You know, things like “We need to prepend to every .asp page these two include lines.” against a 30,000 file heirarchy of a website. Time projected: 2 weeks. Time taken: 5 minutes.

  8. strredwolf says:

    Re: Mad love for bash scripts…

     find . -type f -iname "*.asp" | perl -nle 'system "mv $_ $_.old; cat ~/prelines.txt $_.old > $_"' 

    Hmmm… maybe something else…

    for i in `find . -type f -iname "*.asp"; do mv $i $i.old; cat ~/prelines.txt $i.old > $i; done
  9. pholph says:

    Re: Mad love for bash scripts…

    Yeah, something like that. I don’t keep code like that around, I usually just generate it “on the fly” as I need it.

  10. Phil says:

    Re: Mad love for bash scripts…

    Yeah. And the stuff I do is usually a bit verbose too. I know it can all be buried in a single find command by doing something like:

    find . -type f -iname “*.asp” -exec mv \{} \{}.save && cat prelines.txt \{}.save > \{};

    But using “{}” as a file indicator always feels icky to me. Unreadable too. So like , I usually just slap down something that works and move on.

Leave a Response