openSUSE Forums > Programming/Scripting » Need shell script for processing multiple files

Go Back   openSUSE Forums > Programming/Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


Programming/Scripting Questions about programming, bash scripts, perl, php, cron jobs, ruby, python, etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 17-Sep-2009, 03:59
growbag's Avatar
Parent Penguin
 
Join Date: Jun 2008
Location: Köln, Deutschland
Posts: 996
growbag hasn't been rated much yet
Default Need shell script for processing multiple files

I'm trying to get a list of .bsp files from a long list of .pk3 (.zip) files.

I can do that with one single file as in this example -

Code:
zipinfo filename.pk3 | grep .bsp
But sadly zipinfo doesn't like using the wildcard for in_file_name.

I need to be able to do something like this in a bash script -

Code:
for each <filename.pk3>
  do
      zipinfo <filename> | grep .bsp >> maps.txt
  end
I have no idea how to do that though, any help appreciated
__________________
HP dv6645, Nvidia 8400m-gs, KDE 4.
Reply With Quote
  #2 (permalink)  
Old 17-Sep-2009, 04:32
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,220
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: Need shell script for processing multiple files

Code:
for f in *.pk3
do
  zipinfo $f | grep '\.bsp'
done > maps.txt
Reply With Quote
  #3 (permalink)  
Old 17-Sep-2009, 04:57
growbag's Avatar
Parent Penguin
 
Join Date: Jun 2008
Location: Köln, Deutschland
Posts: 996
growbag hasn't been rated much yet
Default Re: Need shell script for processing multiple files

Fantastic, thanks a million
__________________
HP dv6645, Nvidia 8400m-gs, KDE 4.
Reply With Quote
  #4 (permalink)  
Old 17-Sep-2009, 14:37
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,220
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: Need shell script for processing multiple files

Actually even I forget this sometimes but you should write:

zipinfo "$f" ...

just in case the filename contains whitespace.
Reply With Quote
  #5 (permalink)  
Old 30-Sep-2009, 23:50
Puzzled Penguin
 
Join Date: Sep 2009
Posts: 8
craverii hasn't been rated much yet
Default Re: Need shell script for processing multiple files

Use the find command. For example:

Code:
find . -name "*.pk3" -exec zipinfo -1 {} \;
NOTE: The space before the backslash semicolon is required.
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2