Results 1 to 6 of 6
Hi all,
I am new to linux scripting, I want normal substring of a string that actually is a url as follows
SITEURL/main.php?page=122&type=download_file&fileID=9&user Id=user1&org=org1&mainmenu=main1&submenu=sub1
What I want is a substring ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-13-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 7
Getting substring of String
Hi all,
I am new to linux scripting, I want normal substring of a string that actually is a url as follows
SITEURL/main.php?page=122&type=download_file&fileID=9&user Id=user1&org=org1&mainmenu=main1&submenu=sub1
What I want is a substring like below
org1_user1_main1_sub1
Please help me solve the problem
Thanks in advance
- 09-13-2010 #2
Which programming language do you use? C/C++? Python? Bourne Shell? C Shell? Perl? PHP?
- 09-13-2010 #3Just Joined!
- Join Date
- Sep 2010
- Posts
- 7
Thnx for you quick response.
I have to use linux shell script.
- 09-13-2010 #4
So I assume you use Bourne/Bash scripting language.
I suggest you to learn one thing or two about string manipulation in shell scripts. You may find good resources about this topic a lot, but here is one: Advanced Bash Shell Scripting Guide - Manipulating Strings
This tutorial uses expr for performing regexp operations but you can also use tools like grep or sed
- 09-14-2010 #5Just Joined!
- Join Date
- Sep 2010
- Posts
- 7
Thnx for you help ..
but I am totally new to shell script programming ...
If you can mention some code.. it can help a lot
THanks again..
- 09-16-2010 #6Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
This outputs user1. You can loop through the second line to get the next fields, store in variables and concatenate at will.Code:s="SITEURL/main.php?page=122&type=download_file&fileID=9&user_Id=user1&org=org1&mainmenu=main1&submenu=sub1" echo $s | awk -F "&" '{print $4}' | awk -F "=" '{print $2}'0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.


Reply With Quote
