Hi,
Trying to represent a number with thousands separator in AWK:
echo 1 12 123 1234 12345 123456 1234567 | awk --re-interval '{print gensub(/(])(]{3})/,"\\1,\\2","g")}'
1 12 123 1,234 1,2345 1,23456 1,234567
any idea what is wrong here ? (11 Replies)
Following is the CSV file, separated by ","
100,sunil,$1,000,mumbai
101,amit,$10,000,mumbai
102,sailesh,$10,000,00,mumbai
I want the following output:
100,sunil,$1000,mumbai
101,amit,$10000,mumbai
102,sailesh,$1000000,mumbai
Note: I know the number of fields in the file in advance. In... (2 Replies)
Hello all,
I'm trying to break down a file with the following format:
entries
dzdf
daff
enries
dfln
fnljfd
.
.
..
.
I'm reading this file, using "[" as my separator. It's working quite well, but I would like to be able to read the "[" character into my array as a valid... (4 Replies)
I have tried to use ">" as record separator, but it doesn't work.
I have tried this:
awk BEGIN{RS=">"}'{print $0}' input
output:
awk: BEGIN{RS=>}{print $0}
awk: ^ syntax error
awk BEGIN{RS="\>"}'{print $0}' input
awk: BEGIN{RS=\>}{print $0}
awk: ^ backslash not... (2 Replies)
Hi,
I have a flat file with fields separated by a X'1F'
i have to fetch 4th field from second line.
please help me how to achieve it.
I tried with below command and its not working.
cut -f4 -d`echo -e '\x1f'` filename.txt
I am using SunOS.
Thanks in advance. (2 Replies)
It shows error at 'else', how can I fix it?
if ; then # Note the space after the semicolon.
#+ ^^
echo "File $filename exists."; cp $filename $filename.bak
else # ^^
echo "File $filename not found."; touch $filename
fi; echo "File test complete." (3 Replies)
Hello All,
I need help with the below, I would appreciate any tip.
I have a file as below
Input file
Apple: Green
Banana: Yellow
Grapes: Black
Apple: Red
Banana: Green
Grapes: Green
Grapes: Brown
Apple: Pale Red
Banana: Greenish yellow
Grapes: Brown
Apple: Yellowish... (14 Replies)
Hello All,
I have a file, but I want to separate the file at a particular record with comma"," in the line
Input file
APPLE6SSAMSUNGS5PRICEPERPIECEDOLLAR600EACH010020340URX581949695US
to
Output file
APPLE6S,SAMSUNGS5,PRICEPERPIECE,DOLLAR600EACH,010020340URX581949695,US
This is for... (11 Replies)
Friends have the following code that is correct.
BEGIN { num_reg = 0
suma_iva=0
}
{
num_reg++
suma_iva=suma_iva+int(substr($0, 103,9))
}
END{
printf ("%011d",suma_iva)
}
I have the following problem, I have to do just that but this time... (4 Replies)