Today I had to process some files in a similar way in a bash shell. After trying using pipes, I reverted to for loops. First iterating for all files in a directory and extracting its contents (they were *.tar.bz2):
(...)/pcl-book/c23-spam/sa-pub-corpus> ls 20030228_easy_ham_2.tar.bz2 20030228_hard_ham.tar.bz2 20030228_spam.tar.bz2 20030228_easy_ham.tar.bz2 20030228_spam_2.tar.bz2 (...)/pcl-book/c23-spam/sa-pub-corpus> for f in *; do tar -xjf $f; done
Then, I discovered that the archives contained a file which I didn't wanted, so, I removed the files (the files were named “cmds”):
(...)/pcl-book/c23-spam/sa-pub-corpus> ls 20030228_easy_ham_2.tar.bz2 20030228_hard_ham.tar.bz2 20030228_spam.tar.bz2 easy_ham_2/ spam/ 20030228_easy_ham.tar.bz2 20030228_spam_2.tar.bz2 easy_ham/ hard_ham/ spam_2/ (...)/pcl-book/c23-spam/sa-pub-corpus> for f in `ls --ignore=2003*`; do `rm $f\cmds`; done
No comments:
Post a Comment