![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| stripping white space... | Zak | Shell Programming and Scripting | 7 | 10-09-2007 04:41 AM |
| $PWD shows absolute path vs path w/symbolic links | kornshellmaven | Shell Programming and Scripting | 3 | 06-13-2007 09:15 AM |
| stripping out certain charecters | mervin2006 | Shell Programming and Scripting | 4 | 12-01-2006 05:22 AM |
| vi - replacing a relative path with absolute path in a file | Yinzer955i | UNIX for Dummies Questions & Answers | 2 | 09-07-2006 08:47 AM |
| stripping last character from end of each line | hcclnoodles | UNIX for Dummies Questions & Answers | 6 | 11-21-2005 05:35 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
can anyone help me with stripping an absolute filepath? I did a search on this topic but didnt find anything but maybe I didn't look hard. Anyway, would really appreciate it if anyone could help me. I am a new unix user so this might be a simple issue but I am stuck, don't really understand the use of 'grep'
here is the path that I have (dvrg12 is the server name) and this script is on the same server too //dvrg12/usr/users/user_name/folder1/folder2/file_name ideally I want to return only "/user_name/folder1/folder2/filename" and I obviously know the user_name. thought of using a regular expression to search for the pattern of the server name since its always going to be the same. the format of the server name will be as follows (could be wrong): [a-z]\{4\}[0-9]\{2\} == dvrg12 ?? if I could find the match and return everything after it then it would be ok from there but thats where I am stuck. thanks in advance...could this be as simple as using the cut command? although that would only work if the path I was given always started with 2 forward slashes but what if it starts with only 1 forward slash or starts with no foraward slash? D. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
//dvrg12/usr/users/user_name/folder1/folder2/file_name If the server name changes, try this. Code:
#! /bin/ksh
server=//dvrg12/usr/users/user_name/folder1/folder2/file_name
echo ${server#*users}
Code:
/user_name/folder1/folder2/file_name Code:
#! /bin/ksh
server=//dvrg12/usr/users/user_name/folder1/folder2/file_name
echo ${server#//dvrg12/usr/users}
|
|
#3
|
||||
|
||||
|
Quote:
//dvrg12/usr/users/user_name/folder1/folder2/file_name /dvrg12/usr/users/user_name/folder1/folder2/file_name dvrg12/usr/users/user_name/folder1/folder2/file_name Is there always going to be '/usr/users' in the path? |
|
#4
|
|||
|
|||
|
Quote:
yes the '/usr/users' is always going to be the same but I think the solution above will work just as well and I will try it now. Thanks. D. |
|
#5
|
|||
|
|||
|
Quote:
Ecclesiates |
|||
| Google The UNIX and Linux Forums |