Search Results

Search: Posts Made By: kmsekhar
1,716
Posted By birei
Hi kmsekhar, One way: $ cat infile A...
Hi kmsekhar,

One way:

$ cat infile
A
JACK WAS_${HH}_JACK ....
$ awk 'FNR == 1 { temp = $1; next } FNR == 2 { sub( /\${HH}/, temp ) } { print }' infile
JACK WAS_A_JACK ....
4,758
Posted By itkamaraj
$ nawk -v p=$(cat Par.txt) '$0~p' Input.txt A,1...
$ nawk -v p=$(cat Par.txt) '$0~p' Input.txt
A,1
B,3


if you want to compare in first column then use $1~p
3,466
Posted By knight_eon
awk -F '=' ' { for...
awk -F '=' '
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1;...
3,964
Posted By aigles
Replace space before awk : #!/bin/ksh ...
Replace space before awk :
#!/bin/ksh
filesrc=/usr/kk/Source1.txt
filetgt=/usr/kk/Source2.txt

FINAL_COUNTS=`awk '{n++} END {printf "%012d\n",n}' ${filesrc} ${filetgt}`
 
echo 'Final Count...
3,077
Posted By birei
Hi kmsekhar, One way using 'awk': $ cat...
Hi kmsekhar,

One way using 'awk':

$ cat infile
0001|0003 ...
2,894
Posted By methyl
if [ "${PROCESS_DELTA_CHECK}" -eq "F" ] ; then ...
if [ "${PROCESS_DELTA_CHECK}" -eq "F" ] ; then
ARCHIVE_TGT()
ARCHIVE_SRC()
RENAME_SRC()
CHK_COUNT()
elif [ "${PERIOD_TGT}"-eq"$PERIOD_DELTA_SRC" ] ; then
ACCUMULATE_SRC()
#Timestamp to the...
23,617
Posted By vgersh99
look into 'man fold'
look into 'man fold'
925
Posted By bartus11
Try: awk -F\|...
Try: awk -F\| 'NR==2{d=$0;next}NR==3{n=$0;next}NR>1&&FNR==1&&$3==d{p=1}END{sub(".","");if (p&&$0==n) {print "same fields"}else{print "different fields"}}' file1.txt file2.txt
4
2,251
Posted By yazu
A sketch. Add the first line, remove a space and...
A sketch. Add the first line, remove a space and change to commas if you want by yourself.

awk -F'|' '
NR!=1 {a[$2] = a[$2] " " $1}
END { for (mark in a) print mark "|" a[mark] }
' INPUTFILE
1,725
Posted By neutronscott
awk '!/^$/{ a=substr($0,3,3) if (a ==...
awk '!/^$/{
a=substr($0,3,3)
if (a == "ONE" || a == "TWO" || a == "SIX")
print $0 > a".txt"
}' Input.txt


---------- Post updated at 12:48 PM ---------- Previous update was at 12:42...
1,254
Posted By yazu
#!/bin/sh # Usage: SCRIPT file1 file2 ... ...
#!/bin/sh

# Usage: SCRIPT file1 file2 ...

TEMP=`tempfile`
for f; do
awk 'NR==1{print FILENAME}1' "$f" >$TEMP
mv $TEMP "$f"
done
rm $TEMP
If you don't have "tempfile" you can use ...
1,254
Posted By Corona688
I'm guessing the first b.txt is a typo then,...
I'm guessing the first b.txt is a typo then, since the file is a.txt?

A slight change to that awk script might work, then:

#!/bin/sh

# Usage: SCRIPT file1 file2 ...

# If you don't have...
2,267
Posted By radoulov
You reference the variable with its name (you...
You reference the variable with its name (you should not use $varname):

% awk -v myvar=myvalue 'BEGIN {
print myvar
}'
myvalue
2,267
Posted By agn
$ var='hello' $ nawk -v v=$var 'BEGIN{ print v...
$ var='hello'
$ nawk -v v=$var 'BEGIN{ print v }'
hello
14,188
Posted By Scrutinizer
Well you certainly had the right idea. I noticed...
Well you certainly had the right idea. I noticed that you are using a | as field separator for sort, while the file is comma delimited. Also you should sort on the 2nd field I think if you want to...
4,061
Posted By Franklin52
Create a reference file like: qwe aaaaaa asd...
Create a reference file like:
qwe aaaaaa
asd bbbbbbbb
rty cccccc
tyu uuuuu

and try this command:
awk 'NR==FNR{a[$1]=$2;next} {
for(i=1;i<=NF;i++) {
if(a[$i]){$i=a[$i]}
}
}1'...
Showing results 1 to 16 of 16

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