Register
It is currently Thu Dec 18, 2014 4:50 am

Is this possible? find Pathname with limited info.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Wed May 15, 2013 2:54 pm   

Joined: Fri May 10, 2013 12:23 pm
Posts: 5
Okay so using Bash Script i need to do the following

i need to find this path

"/Users/MacBookAir/Documents/folder1/folder2/star1/star2/star3/star4"

the only thing i am given is ../star1/star2/star3/star4

please keep in mind that sometimes the correct path will be

"/Users/MacBookAir/Documents/folder1/folder2/star1/star2/star3/star4"
or
"/Users/MacBookAir/Documents/folder1/star1/star2/star3/star4"
or
"/Users/MacBookAir/Documents/folder2/star1/star2/star3/star4"
or
"/Users/MacBookAir/Documents/star1/star2/star3/star4"
or
"/Users/MacBookAir/folder1/folder2/star1/star2/star3/star4"
or
"/Users/MacBookAir/folder1/star1/star2/star3/star4"
or
"/Users/MacBookAir/folder2/star1/star2/star3/star4"


now as far as i know /star1/star2/star3/star4 only appears once.

i also have this information
../star1/star2/star3/star4/file1.h"
and
../star1/star2/star3/star4/file2.h"

I have tried
test = find ~/ -name /star1/star2/star3/star4/file.h

and i get the error :too many arguments.


so any idea how i can do this?


Top
 Profile  
 PostPosted: Wed May 15, 2013 8:31 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 579
hi,

and, did you try to read some basic tutorial about shell script writing?


Top
 Profile  
 PostPosted: Thu May 16, 2013 7:45 am   

Joined: Fri May 10, 2013 12:23 pm
Posts: 5
Yes i did read the basic tutorial. Thank you for the advice Watael

reviewing the basic tutorial did eventual lead me to my solution.

the reason why i was thinking that nothing was working was due to the fact that one of my folders was written with parentheses

example: folder1/folder (2)/star1/star2/star3

I didn't realize that when i do cd $1/../star1/star2/star3

due to the parentheses i need to write is as cd "$1/../star1/star2/star3"

Anyhow thank again for all the help, And sorry if I am inexperienced. this is my first time working with Bash scripts.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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