backward string cut


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting backward string cut
# 1  
Old 08-23-2011
backward string cut

I need only the last .ko files to be stripped from the whole result., ie libiscsi2.ko, scsi_transport_iscsi2.ko etc..

kernel/drivers/scsi/libiscsi2.ko
kernel/drivers/scsi/scsi_transport_iscsi2.ko
kernel/drivers/scsi/scsi_transport_iscsi.ko
kernel/fs/nls/nls_utf8.ko
kernel/fs/hfsplus/hfsplus.ko
kernel/drivers/block/loop.ko
kernel/drivers/md/dm-mirror.ko
# 2  
Old 08-23-2011
Code:
sed 's#.*/##' Inp_File

This User Gave Thanks to Shell_Life For This Post:
# 3  
Old 08-23-2011
Thanks a ton it worked Smilie
# 4  
Old 08-24-2011
in awk..
Code:
$ awk -F/ '{print $NF}' inputfile

# 5  
Old 08-24-2011
Alternatively..
Code:
xargs -n1 basename < inputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut the data with a string that has \ in it

Hi Team, Here's the record in a file. abc\USER DEFINED\123\345\adf\aq1 Delimiter here is "\USER DEFINED\" Expected output: abc|123\345\adf\aq1 Find "\USER DEFINED\" and replace it with "|". Can anyone please help us to fix this issue? Please use CODE tags as required by... (5 Replies)
Discussion started by: kmanivan82
5 Replies

2. Shell Programming and Scripting

Cut string substr

friends as I can cut the first three characters in a string example: 400_FACTURACION_CANJES_20151217.txt Result 400 (2 Replies)
Discussion started by: tricampeon81
2 Replies

3. Shell Programming and Scripting

Cut the string

---------- Post updated at 10:31 AM ---------- Previous update was at 10:28 AM ---------- Hello, I am trying to get the string cut based on the following needs: String1=Submitted request 25574824 for CONCURRENT SQLAP RUAPACTUALSEXT Y RUAPACTUALS122313100616.dat "2013/01/12 14:50:44"... (6 Replies)
Discussion started by: cartrider
6 Replies

4. Shell Programming and Scripting

Cut the string

Hi in a directory i've files having the following name for_category_info_19990101984301 for_catgry_meta_19991111214601 ------- I just want the name till year and month i.e; for_category_info_199901 for_catgry_meta_199911 How can i achieve the above string Thanks (2 Replies)
Discussion started by: smile689
2 Replies

5. Shell Programming and Scripting

how to cut all string after the last delimiter?

hi all, suppose a string: abc/def/ghi/jkl/mn.txt and i want to get the file name without the path. however, different files have different paths, therefore the number of delimiter is uncertain. thanks so much! (3 Replies)
Discussion started by: sunnydanniel
3 Replies

6. UNIX for Dummies Questions & Answers

Help With Backward grep

hey, i got 2 files with the following content: file1: LOCAL_GSK1 50:01:24:80:45:f1:15:23 50:01:24:81:45:f1:15:23 50:01:24:82:45:f1:15:23 50:01:24:83:45:f1:15:23 LOCAL_GSK2 50:01:24:82:00:9c:d7:a7 50:01:24:82:01:bc:d7:a7 50:01:24:82:02:dc:d7:a7 50:01:24:82:03:fc:d7:a7 LOCAL_GSK3... (1 Reply)
Discussion started by: boaz733
1 Replies

7. Shell Programming and Scripting

Scripting help- cut the string

Hi I am having a file with the following content(its created by ls of a directory): -rw-r----- 1 321 321 0 Oct 14 10:41 xcv23456 -rw-r----- 1 321 321 0 Oct 14 10:41 xcv23457 -rw-r----- 1 321 321 0 Oct 14 10:41 xcv23458 -rw-r----- 1 321 321 ... (6 Replies)
Discussion started by: digitalage
6 Replies

8. UNIX for Advanced & Expert Users

Substitute single backward-slash with the double backward-slash

Hi, I have a path like this c:\test\sample\programs, i need to change thiis to c:\\test\\sample\\programs. How to perform this? I tried tr command but it didn't help me. Thanks Vijayan (3 Replies)
Discussion started by: mvictorvijayan
3 Replies

9. Shell Programming and Scripting

cut First charecter in any string

I wannt to cut first char of any string. str=A2465443 out put will be. str1=A str2=2465443. I tried str2=${?%srt} str1=${str#$str2} it is not working. (6 Replies)
Discussion started by: rinku
6 Replies

10. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies
Login or Register to Ask a Question