Find the answer to your Linux question:
Results 1 to 2 of 2
Hello. I have the following lines in a for loop, that runs through a list of email accounts and puts it in a file. I want to have the domain ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    1

    Bash: awk string help

    Hello.

    I have the following lines in a for loop, that runs through a list
    of email accounts and puts it in a file. I want to have the domain added
    to start of every line in the output.

    Code:
    domain=`mynameATemail.com | cut -d 'AT' -f2`  #removes the AT and chars before it
    grep $ACCOUNTS | awk {'print $1 "," $2/1024/1024 "," $3/1024/1024'} >> file.csv
    I want to somehow include the $domain in the print, before the $1
    and cant figure out how todo this..

    So code should look something like this:
    Code:
    grep $ACCOUNTS | awk {'print $1 | cut -d 'AT' -f2 "," $1 "," $2/1024/1024 "," $3/1024/1024'} >> file.csv
    But that gives error on the 'AT'...

    Anyone out there that have any good solutions?

    Note: Had to change out the AT sign with AT,
    was not allowed to post with the AT sign

    Thank you in advanced.

    /Sithz

  2. #2
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    Code:
    awk -v DOMAIN=$domain {'print DOMAIN $1 "," $2/1024/1024 "," $3/1024/1024'} >> file.csv

Posting Permissions

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