Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. tar -ztf file.tar.gz | while read FILENAME
  2. do
  3. if tar -zxf file.tar.gz "$FILENAME" -O | grep "string" > /dev/null
  4. then
  5. echo "$FILENAME contains string"
  6. fi
  7. done
  8.  
  9. zgrep -a string file.tar.gz
  10.  
  11. $ tar xf file.tar.gz --to-command "awk '/bar/ { print ENVIRON["TAR_FILENAME"]; exit }'"
  12. bfe2/.bferc
  13. bfe2/CHANGELOG
  14. bfe2/README.bferc
  15.  
  16. tar zxf file.tar.gz
  17. for f in hopefullySomeSubdir/*; do
  18. grep -l "string" $f
  19. done
  20.  
  21. tar xzf example.tgz --to-command 'grep --label="$TAR_FILENAME" -H PATTERN ; true'
  22.  
  23. targrep () {
  24. for i in $(tar -tzf "$1"); do
  25. results=$(tar -Oxzf "$1" "$i" | grep --label="$i" -H "$2")
  26. echo "$results"
  27. done
  28. }
  29.  
  30. targrep example.tar.gz "pattern"
  31.  
  32. tar -ztf file.tar.gz | while read FILENAME
  33. do
  34. (if tar -zxf file.tar.gz "$FILENAME" -O | grep -l "string"
  35. then
  36. echo "$FILENAME contains string"
  37. fi) &
  38. done
  39.  
  40. local tempPath=`tempfile`
  41. mkdir $tempPath && tar -zxf file.tar.gz -C $tempPath &&
  42. find $tempPath -type f | while read FILENAME
  43. do
  44. (if grep -l "string" "$FILENAME"
  45. then
  46. echo "$FILENAME contains string"
  47. fi) &
  48. done && rm -r $tempPath
  49.  
  50. -l, --files-with-matches
  51. Suppress normal output; instead print the name of each input file from which output would
  52. normally have been printed. The scanning will stop on the first match. (-l is specified
  53. by POSIX.)
  54.  
  55. pattern=$1
  56. for f in *.tar.gz; do
  57. echo "$f:"
  58. tar -xzf "$f" --to-command 'grep --label="`basename $TAR_FILENAME`" -Hin '"$pattern ; true";
  59. done
  60.  
  61. tar -xzf "$f" --to-command 'echo "f:`basename $TAR_FILENAME` s:'"$pattern""
  62.  
  63. 'grep --label="`basename $TAR_FILENAME`" -Hin '"$pattern ; true"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement