search="123" tar -tf one.tar | while read filename do if [ -f "${filename}" ] then mv "${filename}" "${filename}.sav" fi # tar -xf one.tar "${filename}" # found=`grep -l "${search}" "${filename}"` if [ ! "${found}""X" = "X" ] then echo "Found \"${search}\" in \"${found}\"" grep "${search}" "${filename}" echo "" fi # if [ -f "${filename}.sav" ] then mv "${filename}.sav" "${filename}" fi done
This blog is organized by a group of friends experienced in managing Windows, Linux and what ever Open Source Operating system you can name :) People call us "System administrators". But we prefer, "A bunch of friends".
Monday, 20 February 2012
Script to grep a word inside a tar file
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment