Search Results

Search: Posts Made By: zulabc
Forum: Programming 03-30-2012
1,385
Posted By Corona688
$ cat csv.awk BEGIN { FS=" *= *" ...
$ cat csv.awk

BEGIN { FS=" *= *"
L=split("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z",FNAMES," ");
}

function print_company()
{
# Generate filename.
#...
1,614
Posted By Chubler_XL
Uses dot and space as field separators, this is...
Uses dot and space as field separators, this is so we can pickup filename without extension (eg bb from bb.txt).

NR==FNR{f=$0;sub(".*/","",f);F[f]=$0;next} Store pathnames in file_2 into array...
1,702
Posted By yinyuemi
awk 'NR%2{$0=$0".h"}1' or awk...
awk 'NR%2{$0=$0".h"}1'
or

awk 'length($0)>2{$0=$0".h"}1'
1,702
Posted By littlefedora
cat yourtext | sed 's/\(.*\_.*\)/\1\.h/g'
cat yourtext | sed 's/\(.*\_.*\)/\1\.h/g'
1,312
Posted By suresh.boddepu
TRY
(pwd;cat File_Name) > OUTPUT_Filename
1,312
Posted By alister
printf %s\\n 1i "$PWD" . w q | ed -s fileRegards,...
printf %s\\n 1i "$PWD" . w q | ed -s fileRegards,
Alister
8,280
Posted By EAGL€
paste -d " " file1 file2 > file3 -d...
paste -d " " file1 file2 > file3

-d indicates delimeter, in your case a space, so set it according to the field seperator in your resulting output field
8,280
Posted By Scrutinizer
Note: gensub is gawk only. Alternatively: awk...
Note: gensub is gawk only.
Alternatively:
awk 'END{for(i=4;i<=9;i++)printf "dd%d %02d\n",i+1000,i}1' infile
8,280
Posted By yinyuemi
awk '{print $0}END{for(i=1004;i<1010;i++) print...
awk '{print $0}END{for(i=1004;i<1010;i++) print "dd"i FS gensub(/..(..)/,"\\1",1,i)}' (file://\\1&quot;,1,i)}')
aa1001 01
bb1002 02
cc1003 03
dd1004 04
dd1005 05
dd1006 06
dd1007 07
dd1008 08...
8,280
Posted By yinyuemi
awk '{print $0}END{print "dd1004 04"}' file or...
awk '{print $0}END{print "dd1004 04"}' file
or sed
sed '$a dd1004 04'
8,280
Posted By Scrutinizer
awk can treat numbers as numeric strings or as...
awk can treat numbers as numeric strings or as numbers depending on the context. If you add 0 to the number then you are forcing it into numeric context, which means it is interpreted as a number and...
8,280
Posted By yinyuemi
"+", using as that way in awk, is a Mathematical...
"+", using as that way in awk, is a Mathematical operator
8,280
Posted By Scrutinizer
awk '$2=sprintf("%02d",$2)' file
awk '$2=sprintf("%02d",$2)' file
8,280
Posted By suresh.boddepu
TRY
awk '{print $1 " " substr($2,5,2)}' File_Name
8,280
Posted By yinyuemi
()?: is a short form of if condition code, here, ...
()?: is a short form of if condition code, here,
$2=($2>10)?$2+0:"0"$2+0 can be explained as:
{if ($2>10) {$2=$2} else {$2="0"$2+0}}
8,280
Posted By yinyuemi
awk '$2=($2>10)?$2+0:"0"$2+0' file
awk '$2=($2>10)?$2+0:"0"$2+0' file
8,280
Posted By ctsgnb
echo "NAME TYPE" | cat - infile ----------...
echo "NAME TYPE" | cat - infile

---------- Post updated at 09:27 AM ---------- Previous update was at 09:22 AM ----------

nawk 'NR<2{print "NAME TYPE"}1' infile
8,280
Posted By yinyuemi
How about this? awk 'NR==1{$0="NAME...
How about this?

awk 'NR==1{$0="NAME TYPE\n"$0;print}NR>1'
8,280
Posted By Scrutinizer
@yinyuemi, to remove those 4 zeroes the...
@yinyuemi, to remove those 4 zeroes the parentheses are not required...
sed 's/0\{4\}//'
or just
sed s/0000//
Showing results 1 to 19 of 19

 
All times are GMT -4. The time now is 10:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy