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

    Unhappy Problem with string append

    Hi all,

    I am new to linux shell script and I am currently facing a strange problem. Currently I am working on , in which I have a string and I have to parse it to a specific string.

    My problem is as like below.

    echo $str1
    # data1_data2_data3_data4 /. this string I have got from substring of main string
    # now what I want to do is

    echo $a
    # that should print data1_data2_data3_data4_dt5_dt6.pdf but instead it prints like below "_dt4_dt6.pdfdata3_data4"

    # in short it replaces str1's data with the str2's data from starting of str1

    Please help me to solve this strange problem

    Thanks in advance

  2. #2
    Linux User
    Join Date
    Jan 2007
    ok, here's to try:

    1. make a "str0" that contains and underscore '_'

    2. paste -d " " str1 str0 str2 >str3

    3. tr -d " " <str3 >str4

    4. then str4 should be what you want
    the sun is new every day (heraclitus)

  3. #3

    Red face

    Thanks for replying..

    I have tried your code but it gives me following error

    $str3: ambiguous redirect

    I am copying my code here,

    echo "sub Final 0 :" $PDFNM // prints "data1_data2_data3_data4"
    echo "PI :" $PI // prints "dt5_dt6.pdf"

    -d " " $PDFNM $str0 $PI >$str3 //gives error @ this line & below line
    tr -d " " <$str3 >$str4
    echo $str4

    I might be wrong in syntax, as I am totally new in shell scripts...Please help me solve this issue

    Thanks again

  4. $spacer_open

Posting Permissions

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