Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Unhappy 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


    Please help me solve the problem

    Thanks in advance

  2. #2
    Which programming language do you use? C/C++? Python? Bourne Shell? C Shell? Perl? PHP?

  3. #3
    Thnx for you quick response.
    I have to use linux shell script.

  4. $spacer_open
  5. #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

  6. #5


    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..

  7. #6
    Linux User
    Join Date
    Nov 2009
    echo $s | awk -F "&" '{print $4}' | awk -F "=" '{print $2}'
    This outputs user1. You can loop through the second line to get the next fields, store in variables and concatenate at will.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts