Field identification starting from the right


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Field identification starting from the right
# 1  
Old 08-06-2005
Field identification starting from the right

Hi all

If I have lines in a file as follows :-
/ora04/oradata/data1/data1.dbf
/ora01/app/product/8.1.6/dbs/F1.Dbf
/ora04/oradata/data2.dbf

How can I select the last part of the line as my file name. Can I start from the right and define "/" as my delimeter ?

Thx

J
# 2  
Old 08-06-2005
Code:
echo '/a/b/c/d' | sed 's#.*/\(.*\)#\1#'

# 3  
Old 08-07-2005
Puuurfect !!!!!!!!!
Thank you
One last question on this. How do I capture the rest of the line from the position where field 1 ends.
e.g.

Field1=`echo '/a/b/c/d' | sed 's#.*/\(.*\)#\1#'`

Restof= ?

output
Field1=d
Restof=/a/b/c/

Thx

J
# 4  
Old 08-07-2005
Code:
RestOf=`echo '/a/b/c/d' | sed 's#\(.*\)/.*#\1#'`

you might consider looking into dirname/basename
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

2. Shell Programming and Scripting

Select only the lines of a file starting with a field which is matcing a list. awk?

Hello I have a large file1 which has many events like "2014010420" and following lines under each event that start with text . It has this form: 2014010420 num --- --- num .... NTE num num --- num... EFA num num --- num ... LASW num num --- num... (9 Replies)
Discussion started by: phaethon
9 Replies

3. UNIX for Dummies Questions & Answers

iNode Usage Identification

Hi My SunOS alps 5.10 Generic_125100-05 sun4v sparc SUNW,Sun-Fire-T200 appears to have reached 100% util on its iNodes. # df -F ufs -o i Filesystem iused ifree %iused Mounted on /dev/md/dsk/d0 4857202 14 100% / /dev/md/dsk/d20 1040 630640 ... (1 Reply)
Discussion started by: rob171171
1 Replies

4. Shell Programming and Scripting

parameter identification problem

Hello everyone suppose i have a script which can take any no. of parameters and in any order then how can i identify a particular parameter at which position it is entered suppose i call a script with four parameter ./abc.sh a b c d in above calling a is called at no. 1... (3 Replies)
Discussion started by: aishsimplesweet
3 Replies

5. Shell Programming and Scripting

file identification

hi there, i have written the following simple lines: find $SCENE -name "*.xml" echo -n "Input the name of the image file to be read: " set im_name = ($<) i like to set the value for im_name automatically to the .xml, which was found by the first line without having to input it. the... (4 Replies)
Discussion started by: friend
4 Replies

6. Shell Programming and Scripting

Remove field starting with * and #

Hi i have file with data: abc,*xyz,#abc 123,#123,1234 *123,#123,abc So i want to remove only fields starting with * and # and i want output as: abc,, 123,,1234 ,,abc Please suggest something Thanks Sumit (3 Replies)
Discussion started by: sumit207
3 Replies

7. UNIX for Dummies Questions & Answers

file identification

Can anybody tell me what are these files are and what do they do and if they are safe to delete. Thanks /var/cache/yum/base # ls -al total 44792 drwxr-xr-x 4 root root 4096 Sep 22 11:43 . drwxr-xr-x 10 root root 4096 Nov 18 2007 .. -rw-r--r-- 1 root root 0 Sep 22... (5 Replies)
Discussion started by: mcraul
5 Replies

8. UNIX for Dummies Questions & Answers

ip identification

how can i find my own ip address from unix. command like who -x .this would provide all the ip address but i need to list only current user ip address. who am i command does not display the ip. (1 Reply)
Discussion started by: naushad
1 Replies

9. Shell Programming and Scripting

version identification

Hi Which command do i use to know which version of solaris am i working on?? thanks in advance regards (1 Reply)
Discussion started by: knopix
1 Replies

10. Solaris

file identification

Can anyone identify what this file is for? 241436 Dec 17 16:29 dtdbcache_:0 Is it necessary? My system is at 94% and I am trying to clean / directory as much as possible. Any other files I can set to dev/null besides messages, and the wtmp and wtmpx? Please and Thanks. (3 Replies)
Discussion started by: mnsalazar
3 Replies
Login or Register to Ask a Question