sed help
I have a <newline> separated list of files at various websites. eg.
Code:
http://blah.com/thing1.tar.gz I think I can figure out the rest, but I'm having trouble working out a sed statement to take a line of text and remove everything before and including the last forward slash. So I'm just left with a filename. |
How about param expansion
Code:
t='http://blah.com/thing1.tar.gz' |
Try this script
Code:
#/bin/bash This script will extract the filename from the http link and check the current directory for existence of file or not Bonus Code with Awk: Code:
awk -F "/" '{print $NF }' list |
Thanks guys, it worked great.
|
You're welcome mreff555
Mark the thread solved from the threads tool if you feel it was solved. |
Quote:
Also, when using advanced shells like bash or ksh, it's recommended to use [[..]] for string/file tests, and ((..)) for numerical tests. Avoid using the old [..] test unless you specifically need POSIX-style portability. http://mywiki.wooledge.org/BashFAQ/031 http://mywiki.wooledge.org/ArithmeticExpression If you use single brackets you have to make sure to enclose the string in quotes so that it's properly protected from word-splitting and glob expansion. And finally, the formatting could be a bit cleaner. I'd personally write it more like this: Code:
#/bin/bash |
Quote:
|
Quote:
+1 |
Quote:
|
All times are GMT -5. The time now is 07:06 PM. |