Truncate folder path


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Truncate folder path
# 1  
Old 02-14-2011
Truncate folder path

Hello,

Given below are 2 sample paths from 2 different servers:

/opt/temp/PROD/Script/New/Letters

/opt/Share/temp/Share1/PROD/Script/Files/New/Letters


I would like to truncate the path till the folder "PROD". Please note that the field count of the folder "PROD" vaires from server to server


The output I would like to get for the above 2 examples:

/opt/temp/PROD/

/opt/Share/temp/Share1/PROD/



Thanks,
Nishanth
# 2  
Old 02-14-2011
Code:
 sed 's#PROD/.*#PROD#' myFile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

Compiling fails due to space in path to home folder

I seem to have issues compiling software and I think I've narrowed it down to something having to do with having a space in the path name to my Home folder (which contains "Macintosh HD"). The reason I think this is shown here: $ echo $HOME /Volumes/Macintosh HD/Users/Tom $ cd $HOME -sh:... (7 Replies)
Discussion started by: tdgrant1
7 Replies

2. UNIX for Dummies Questions & Answers

How to unmount a folder and do check disk only in that path

I need to check if a folder has some kind of logic disk problems. I have a FreeBSD machine where the (root)\tmp\TEST folder has some file created by a script that i cannot delete. If i rename the tmp\TEST folder then i can delete them (apparently) but if i recreate a folder in tmp directory... (2 Replies)
Discussion started by: mirrorx
2 Replies

3. AIX

tprof, truncate the process path

Hi, i tryed tprof -skex sleep 6 but... Process PID TID Total Kernel User Shared Other Java ======= === === ===== ====== ==== ====== ===== ==== wait 57372 77863 31.31 31.31 0.00 0.00 0.00 0.00 wait ... (1 Reply)
Discussion started by: zanac
1 Replies

4. Shell Programming and Scripting

Need to extract a folder from a full path

Hi everyone, I have different folders which looks like this: /mnt/ecrm/master/ecrm/templates/brochure/de_DE/zeitlos.ott /mnt/ecrm/master/ecrm/templates/mail/en_US/default.html /templates/header_and_footer/en_US/default.txt I want to get the bold text only in a variable. I already have a... (3 Replies)
Discussion started by: evilass
3 Replies

5. Shell Programming and Scripting

Given a path get the last folder in the path

Hi, I have a path such as: PATH= "/home/user/Desktop/folder1/folder2"and I want to output the last folder in the path i.e. "folder 2" Any idea how I should do this? grep? Thanks! (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. Shell Programming and Scripting

Truncate path and keep only filenames

Hi everyone, I have a question for you, I'm trying to create a script that will automate creating loading screens for the iPhone. So what I need to do, is list the directories inside /var/mobile/Applications and scan inside those, for the .app directory inside each. Take that .app name... (15 Replies)
Discussion started by: kicker75
15 Replies

7. Shell Programming and Scripting

command to list files with path & date in a folder

Hi, I need command to display files with full path and date of files where are generated at every 5hrs in a folder. eg: /u01/app/test/orjthsd_1_1 Sun May 10 19:03:26 2009 /u01/app/test/weoiusd_1_1 Sun May 10 21:00:26 2009 thanks saha (3 Replies)
Discussion started by: saha
3 Replies

8. UNIX for Dummies Questions & Answers

ls + folder path

I am using ls -l -R to view all the files in the parent directory and sub -directories. Is it possible to view the path of the files in another column. (1 Reply)
Discussion started by: soumodeep123
1 Replies

9. Windows & DOS: Issues & Discussions

How can I upload a zip folder on a unix path from my windows folder?

Hello, I am an amature at UNIX commands and functionality. Please could you all assist me by replying to my below mentioned querry : How can I upload a zip folder on a unix path from my windows folder? Thanks guys Cheers (2 Replies)
Discussion started by: ajit.yadav83
2 Replies

10. Shell Programming and Scripting

Truncate directory path

Is it possibe to use sed for the following? I would like to truncate the output of a directory path if it's over 3 directory levels deep. For example: /dir1/dir2/dir3 -- NO change required but, /dir1/dir2/dir3/dir4 would output as ~/dir4 Thanks. (4 Replies)
Discussion started by: here2learn
4 Replies
Login or Register to Ask a Question