Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
how to parse a path in unix
Name: NeedHelp Date: June 7, 2002 at 06:38:12 Pacific
Comment:
Hello,
If i have the following in a unix script:
echo "Enter the full path: \c" read PATH
The user will input something like:
/mike/hobbies/football
How can I now take the variable PATH that the user inputted with the full path and parse it so I can save each directory path to a seperate variable, for example I will want to accomplish this in my script:
Path1=mike Path2=hobbies Path3=football
Where Path1, Path2, Path3 are unix variables I want the user input to be saved. Basically how do I parse it and not store the /
Name: LANkrypt0 Date: June 7, 2002 at 08:16:46 Pacific
Reply:
I would suggest that, but my shell provider runs an old version of KSH so that pipe to read does not work :)
0
Response Number 4
Name: James Boothe Date: June 7, 2002 at 13:53:42 Pacific
Reply:
Bummer! I use that a lot. Also, NeedHelp did not say if the number of slashes in the path can vary. If so, the following code would assign the segments to path1, path2, path3, etc.
n=0 for word in `echo $mypath | tr "[/]" "[ ]"` do n=`expr $n + 1` eval path$n=$word done
0
Response Number 5
Name: LANkrypt0 Date: June 7, 2002 at 14:00:58 Pacific
Reply:
I wish I could, oh well. I just make do with what I have.
0
Response Number 6
Name: Sean Miller Date: June 13, 2002 at 03:09:26 Pacific
Summary: Hi, How to parse a file that has more than 199 columns. 'awk' fails when line is having more than 199 fields. Is there a way to resolve this...what i am thinking is to strip off all those columns be...
Summary: how to pass a variable from unix environment to oracle procedure ? ex: actual_file_name=`head -1 $IMINT_OWBHOME/temp|tail -1` $ORA_BIN_HOME/sqlplus $IMINT_STG_USER/$IMINT_STG_PASSWD@$IMINT_STG_TNS exe...
Summary: Hi folks, Does anybody know how to list a directory in real time. (sort of what tail -f would do for a file), I need to be able to constantly poll a directory every 100miliseconds or so to see if a ne...