Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 16 of 16
Code: host@~/> which nawk /usr/bin/nawk so i replaced 1st line with #!/usr/bin/nawk but got an Code: host@~/> ./try test -bash: ./try: usr/bin/nawk: bad interpreter: No such file or directory Got ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    119

    Code:
    host@~/> which nawk
    /usr/bin/nawk
    so i replaced 1st line with #!/usr/bin/nawk

    but got an

    Code:
    host@~/> ./try test
    -bash: ./try: usr/bin/nawk: bad interpreter: No such file or directory
    Got it, I assume you were running on Linux so my bad! And I think you just need to make the first line: #!/usr/bin/nawk -f
    (meaning add the "-f" to what you tried) and it should be directly executable. But you can explicitly run it with "nawk" as well, so you're all set.

  2. #12
    o28
    o28 is offline
    Just Joined!
    Join Date
    Jul 2012
    Posts
    9
    thanks for help!!!!! how do you know all these things guys!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!?

  3. #13
    o28
    o28 is offline
    Just Joined!
    Join Date
    Jul 2012
    Posts
    9
    so here what I have with your help

    Code:
    #!/bin/bash
    rm cell-data.txt
    #content for cell-data.txt
    echo "Paste data for UPDATE correction:"
    echo "enter \"^\" when done"
    #getting information for update
    while read LINE
    do
    echo $LINE >> temp
    if [ "$LINE" = "^" ];then
    break
    fi
    done
    sed 's/\^//g' temp | sed '/^$/d'  > cell-data.txt
    # filter only amount and msisdn 
    file=./cell-data.txt
    while read line; do
      col1=$(echo $line|awk '/^[0-9]/{print $1}')
      echo $col1|grep -q _$
      if [ $? -eq 0 ]; then
        ac=$(echo $line|awk '/^[0-9]/{print $2}')
        cn=$(echo $line|awk '/^[0-9]/{print $3}')
      else
        cnt=$(printf "$col1"|wc -c)
    
        if [ $cnt -eq 0 ]; then
          continue
        elif [ $cnt -eq 11 ]; then
          cn=$col1
          ac=$(echo $line|awk '/^[0-9]/{print $2}')
        else
          ac=$col1
          cn=$(echo $line|awk '/^[0-9]/{print $2}')
        fi
      fi
      ac=$(echo $ac|sed -e 's|,|.|')
      echo $ac $cn
    done < <(cat $file) > result
    # add 7 to not full msisdn and order in fields 
    # nawk script named try in the same folder 
    nawk -f try result > result2
    # printing the command for update
    awk '{print "updbl""\t"$2"\t""BLP_Main""\t""\"\"""\t""-"$1"\t""\"\"""\t""\"\"""\t""C=COR:Res=COR:C_EXT=COR:UID=o"}' result2 > update
    cat update
    echo ""
    cp update /input/`date +%F_%T`_o.dpd
    echo ""
    ls -rt /input/ | tail -2
    echo ""
    echo ""
    echo "ls -rt /input/ | tail -2"
    rm result
    rm result2
    rm temp
    exit 0
    It's almost everything that i needed!!!


    thank you one more time guys!!!

  4. #14
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    119
    I'm glad to hear you got something working the way you need. So just two closing comments from me...

    First, I think the code atreyu and I posted do the same thing so you don't need to run them both. In fact I'm surprised that works. Also you could edit the lines that display the reformatted output in either script to include the "updbl"###"BLP_Maint"..." formatting and not have to create another temporary file. It might be a good "homework assignment" to get more comfortable with the code.

    Also learning this stuff is just an iterative process of writing scripts, running into problems, figuring out how to solve them, then writing more scripts. Repeat ad nauseam and eventually you learn a few tricks. So just keep doing it. Practice really does beat the knowledge into your brain.

  5. #15
    o28
    o28 is offline
    Just Joined!
    Join Date
    Jul 2012
    Posts
    9
    OK! i'll try!!!

    Thanks everyone guys!!!

  6. #16
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Quote Originally Posted by cnamejj View Post
    I'm glad to hear you got something working the way you need. So just two closing comments from me...

    First, I think the code atreyu and I posted do the same thing so you don't need to run them both. In fact I'm surprised that works. Also you could edit the lines that display the reformatted output in either script to include the "updbl"###"BLP_Maint"..." formatting and not have to create another temporary file. It might be a good "homework assignment" to get more comfortable with the code.

    Also learning this stuff is just an iterative process of writing scripts, running into problems, figuring out how to solve them, then writing more scripts. Repeat ad nauseam and eventually you learn a few tricks. So just keep doing it. Practice really does beat the knowledge into your brain.
    I agree w/cnamejj on both points, well said.

Page 2 of 2 FirstFirst 1 2

Posting Permissions

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