Editing a command-line argument to create a new variable

Posted by user1883614 on Ask Ubuntu See other posts from Ask Ubuntu or by user1883614
Published on 2012-12-07T04:28:14Z Indexed on 2012/12/07 5:21 UTC
Read the original article Hit count: 208

Filed under:
|
|

I have a bash script called test.sh that uses command-line argument:

lynx -dump $1 > $name".txt"

But I need name to be created from the argument by specific keywords in the argument.

An example is:

http://www.pcmag.com/article2/0,2817,2412941,00.asp
http://www.pcmag.com/article2/0,2817,2412919,00.asp

Both are two separate articles but are the difference can only be seen in those 12 characters. How do I create a variable from a url for those 12 characters? So that when I run test.sh in Terminal:

./test.sh http://www.pcmag.com/article2/0,2817,2412941,00.asp 

there is a text file saved as 0,2817,2412941,00?

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about bash