Register
It is currently Fri Oct 31, 2014 4:54 pm

unrar and search file names


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Mon Dec 26, 2011 2:35 am   

Joined: Mon Dec 26, 2011 2:24 am
Posts: 2
Hello,
I am new to bash. I need a script.Here is what I am trying to achieve.
I have a .rar file . Inside this rar is lot of small rar files. I want to unrar the main rar file in a folder.Then search names of the files for a specific set of chars like "Aliens" (not case sensitive) And then if it find the file name containing this set of chrs it should extract its contents in a specific folder.

I have just started reading a tutorial on bash but dont have enough time to go through it all. Can some one pls point me to right direction.
Thank You.


Last edited by randomidiot on Mon Dec 26, 2011 3:43 am, edited 1 time in total.

Top
 Profile  
 PostPosted: Mon Dec 26, 2011 3:27 am   

Joined: Mon Dec 26, 2011 2:24 am
Posts: 2
Ok I am using following code to unrar only file name with certain string in it

Code:
#!/bin/bash

destdir= "/home/user/dir1"

for FILENAME in "`find -name "*alien*" -print0`"
do
echo $FILENAME
unrar t $FILENAME  destdir
done
exit


I get error
Code:
ERROR: Unknown option:


what am i doing wrong? (edit: I get file names all right)


Top
 Profile  
 PostPosted: Sun Jan 01, 2012 10:37 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
This line:

unrar t $FILENAME destdir

should probably look like this

unrar t $FILENAME $destdir

I think you forgot a "$".

HTH's


Top
 Profile WWW  
 PostPosted: Wed Jan 04, 2012 12:56 pm   
User avatar

Joined: Sat Jul 02, 2011 10:43 am
Posts: 23
Location: Devon,UK
I would use the $( ) syntax for command substitution instead of backticks , its easier to read.
use -iname for a case insensitive search to find, -name is case sensitive.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP