Skip to content

Instantly share code, notes, and snippets.

@fabienhinault
Created April 30, 2014 14:59
Show Gist options
  • Save fabienhinault/5539837a0bb11558f365 to your computer and use it in GitHub Desktop.
Save fabienhinault/5539837a0bb11558f365 to your computer and use it in GitHub Desktop.
#!/bin/bash
find -name *.txt | grep "[0-9]\{8\}-[0-9]\{6\}\.[0-9]\{3\}" | sed -n "s/\(^.*\)[0-9]\{8\}-[0-9]\{6\}\.[0-9]\{3\}-\(.*$\)/mv '&' '\1\2'/p" | sh
i=2
while (( $i<10 ))
do
find -name "*\[0$i\].txt" | sed -n "s/\(^.*\)\[0$i\]\(\.txt$\)/cat '&' >> '\1\2' \&\& rm '&'/p" | sh
let "i++"
done
find -name *.txt -print0| xargs -0 sed -i~ -f ./cmp.sed
s,^#[0-9]\{6\} [0-9]\{4\}/[0-9]\{2\}/[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}\.[0-9]\{3\} \(.*\)$,\1,p
s,#[0-9]\{4\}/#[0-9]\{4\},,p
s,([0-9][0-9]*),(),p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment