Find the answer to your Linux question:
Results 1 to 3 of 3
Hey there gurus, fans, and students alike! I have another Q about sed. First let me show you my almost working scenario: Code: #!/bin/bash QTDO="/mmc/mmca1/.system/QTDownLoad/CKC" BUSY="$QTDO/busybox" EZXP="$QTDO/ezxpopup" SHOW="$QTDO/showQ" YAN0="$QTDO/yan0_notes" # ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    8

    Bash Scripting: Is this possible?

    Hey there gurus, fans, and students alike! I have another Q about sed. First let me show you my almost working scenario:

    Code:
    #!/bin/bash
    
    QTDO="/mmc/mmca1/.system/QTDownLoad/CKC"
    BUSY="$QTDO/busybox"
    EZXP="$QTDO/ezxpopup"
    SHOW="$QTDO/showQ"
    YAN0="$QTDO/yan0_notes"
    
    # ezxpopup and showQ are binaries that allow GUI interaction b/w the user and phone.
    # yan0_notes is a unix text editor for my phone, the ROKR e6.
    # ezx_hardkey.cfg is a config file that contains app codes that are set to some a custom key, and a carrier set key (non customizable from the phone).
    
    echo '' > name
    NAME="$(cat name)"
    $BUSY awk '/customizedKey/ {print $3}' ezx_hardkey.cfg > code
    sed -e 's/$/ $NAME/' code > new
    cat new >> list
    What I am trying to do is end up with a file like this:

    Code:
    8a2b9b37-83e7-a8d9-82cf-0bcbe2070002 AppNameHere
    I need the space between the appcode and the appname.

    How can I use sed in that way? Would I have to write a sed script?

    To be clear, I need the sed command to find the end of the line, add a space and the inputed string from the NAME variable, or the name file... Is this even possible? I've searched all over the net and couldn't find a single article about sed that mentioned recalling variables or files within the sed statement. Thanks everyone!

  2. #2
    Just Joined!
    Join Date
    Mar 2006
    Posts
    5
    Quote Originally Posted by Imahottguy View Post
    Hey there gurus, fans, and students alike! I have another Q about sed. First let me show you my almost working scenario:

    Code:
    #!/bin/bash
    
    QTDO="/mmc/mmca1/.system/QTDownLoad/CKC"
    BUSY="$QTDO/busybox"
    EZXP="$QTDO/ezxpopup"
    SHOW="$QTDO/showQ"
    YAN0="$QTDO/yan0_notes"
    
    # ezxpopup and showQ are binaries that allow GUI interaction b/w the user and phone.
    # yan0_notes is a unix text editor for my phone, the ROKR e6.
    # ezx_hardkey.cfg is a config file that contains app codes that are set to some a custom key, and a carrier set key (non customizable from the phone).
    
    echo '' > name
    NAME="$(cat name)"
    $BUSY awk '/customizedKey/ {print $3}' ezx_hardkey.cfg > code
    sed -e 's/$/ $NAME/' code > new
    cat new >> list
    What I am trying to do is end up with a file like this:

    Code:
    8a2b9b37-83e7-a8d9-82cf-0bcbe2070002 AppNameHere
    I need the space between the appcode and the appname.

    How can I use sed in that way? Would I have to write a sed script?

    To be clear, I need the sed command to find the end of the line, add a space and the inputed string from the NAME variable, or the name file... Is this even possible? I've searched all over the net and couldn't find a single article about sed that mentioned recalling variables or files within the sed statement. Thanks everyone!
    your example isnt very clear and importantly lacks an example source data
    and you failed to post the true current contents of list


    however a space is represented by usually closed with single quotes ' '

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    37
    I don't see why you need the files 'name', 'code' and 'new', nor why you use 'cat' and 'sed'.
    Code:
    #!/bin/bash
    
    QTDO="/mmc/mmca1/.system/QTDownLoad/CKC"
    BUSY="$QTDO/busybox"
    
    NAME="Rosegarden"
    $BUSY awk -v shell_var=" $NAME" '/customizedKey/ {print $3 shell_var}' ezx_hardkey.cfg >>list

Posting Permissions

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