Variable directory name in path


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Variable directory name in path
# 1  
Old 09-18-2009
Variable directory name in path

I need to write a login script for multiple computers, however, one of the directories in question will have a different name from computer to computer.

Code:
~/Library/Application\ Support/Firefox/Profiles/<unique filename>.default/myfile

For the directory named <unique filename>.default , I need to figure out how to get a wildcard going or set a variable so that I can create a file in a directory below it. All computers will have the .default extension on that directory, but different strings will preceed the dot. I imagine I can do a grep with a wildcard and then set a variable based on the results, but if that is the easiest way, I still would need help to accomplish it. Thanks for your time!
# 2  
Old 09-18-2009
Is there any relationship between any of the information you have and the unique directory name (ud for short)? For instance, based on node name and user id? Is there
any expectation of any other directory having the name ud.default in the parent directory?
If not, then maybe u can use *. That will depend on where and what command is executed.

Going to need all the normal info for anyone to help..

1. What are the environmentals (os, shell, etc)
2. What is the big picture of the problem.
3. Is the script expected to run on one machine or several?
4. What are you grep'ing to get the info?
# 3  
Old 09-18-2009
I'm not sure that I have correctly understood your problem. To have different dir names for different users you may variable, e.g.
Code:
~/Library/Application\ Support/Firefox/Profiles/${NAME_OF_YOUR_VARIABLE}.default/myfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What is the difference ../directory path and ./directory path in ksh?

What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies

2. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

3. Shell Programming and Scripting

Variable of Path directory is not parsing in awk

Hi All, i had to split one files into 10 equally. For that i have coded below awk. OUTPUT_FILE=/home/sit/path/Files/file_EXPORT.lst DIR_NM=`dirname ${OUTPUT_FILE}` awk -v CURR_DATE="$(date +'%d-%m-%Y-%H-%M')" -v pth=$DIR_NM '{print >> pth/"tgt_file_name"CURR_DATE"_"NR%10 }' ${OUTPUT_FILE} ... (7 Replies)
Discussion started by: looney
7 Replies

4. UNIX for Advanced & Expert Users

How can i assign directory path to a variable in perl?

Hai how can I assign directory path to a variable in perl Thanks&Regards kiran (3 Replies)
Discussion started by: kiran425
3 Replies

5. UNIX for Dummies Questions & Answers

How can i assign directory path to a variable in perl?

Hai how can I assign directory path to a variable in perl Thanks&Regards kiran (2 Replies)
Discussion started by: kiran425
2 Replies

6. UNIX for Dummies Questions & Answers

Find command fails when a space is in the directory path variable

I have a script like this running under OS X 10.8. The problem arises when the find command encounters a space in the path name. I need the "dir" variable as I'll be extending the script to more general use. #!/bin/bash CFS=$IFS IFS=$(echo) set dir = "/Users/apta/Library/Mail\... (3 Replies)
Discussion started by: apta
3 Replies

7. Shell Programming and Scripting

Custom directory path variable

I'm trying to write my first shell script and got a bit stuck with this: I've got myscript.sh that executes from /fromhere. If the script is run with the syntax ./myscript.sh tothere: I need to make a variable inside the script containing /fromhere/tothere ...and if the script is run with... (10 Replies)
Discussion started by: Chronomaly
10 Replies

8. Shell Programming and Scripting

Retrieve directory path from full file path through sh

Hi, I have a file abcd.txt which has contents in the form of full path file names i.e. $home> vi abcd.txt /a/b/c/r1.txt /q/w/e/r2.txt /z/x/c/r3.txt Now I want to retrieve only the directory path name for each row i.e /a/b/c/ /q/w/e/ How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies

9. Shell Programming and Scripting

one liner to extract path from PATH variable

Hi, Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable? for eg: suppose the PATH is being set as follows PATH=/usr/bin/:/usr/local/bin:/bin:/usr/sbin:/usr/bin/java:/usr/bin/perl3.4 ... (2 Replies)
Discussion started by: royalibrahim
2 Replies

10. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies
Login or Register to Ask a Question