Kawson
Kawson

Reputation: 136

What means sed "1,\$s#.*/##" Linux bash

i have a question, its new for me. I have to learn scripting in bash. Can someone tell me what this line mean?

sed "1,\$s#.*/##"

I'm looking for it since 2 hours. Only i know (i think i know) is that from first word to end of line (because of 1,\$s) then i dont know what means #.*/## (. is single char, *>=0 and # comment, please correct me if im wrong). For example in this case:

213.241.37.114"/vol/1/ftp.cdlinux.pl/iso/v0.5/MD5SUM   

it prints MD5SUM.

Upvotes: 0

Views: 660

Answers (1)

glenn jackman
glenn jackman

Reputation: 246942

The x,y part is an address range, not a "word" range: it means from the first line to the last line. See 4 Addresses: selecting lines

The s/// command can use different delimiters than / -- in this case # is used. 3.3 The s Command

In the whole file, we are searching for the regular expression .*/ and replacing it with nothing -- getting the text after the last slash.

Upvotes: 2

Related Questions