Search Results

Search: Posts Made By: angshuman
4,976
Posted By Don Cragun
If myfile.txt contains: 1|1|1 1|-1|1 1|1|-1...
If myfile.txt contains:
1|1|1
1|-1|1
1|1|-1
1|-1|-1
1|2|3
1|-2|3
1|2|-3
1|-2|-3
1|5|4
1|-5|4
1|5|-4
1|-5|-4
and we change your script to use a more common definition of an absolute value...
1,690
Posted By RudiC
Using your NEW example input file - not the one...
Using your NEW example input file - not the one from post#1 - and the explanation you gave in post #7, the awk script
awk -F\| '!$5 {$5 = (LAST13 == $1 FS $3)?LAST4:"CONST"} 1; {LAST13 = $1 FS $3;...
4,696
Posted By Akshay Hegde
Try [akshay@localhost tmp]$ cat f ...
Try

[akshay@localhost tmp]$ cat f
aa|08/01/2016
bb|08/15/2016
[akshay@localhost tmp]$ awk 'BEGIN{FS=OFS="|"}{split($2,d,/\//);$2=mktime(d[3] " " d[2] " " d[1] " " "00 00 00")}1' f...
2,548
Posted By RavinderSingh13
Hello angshuman, Could you please try...
Hello angshuman,

Could you please try following and let me know if this helps.

awk -F"|" FNR==NR'{A[$1,$4]=A[$1,$4]>$2?A[$1,$2]:$2;next} (($1,$4) in A){print;delete A[$1,$4]}' Input_file ...
2,018
Posted By RavinderSingh13
Hello angshuman, I am not at all sure about...
Hello angshuman,

I am not at all sure about your Input_file and expected output. As you are saying column 1 and column 2 should be common then it shouldn't be that count which you have posted.
...
4,335
Posted By Ivo Breeden
join using join command
why not use the join command to join files? The problem is it only can join on 1 field in each file (default the first field in each file). But after the first join it gets much easier.

$ join -t...
3,121
Posted By RudiC
awk '/^120/ {REC++; SUM+=$26;...
awk '/^120/ {REC++; SUM+=$26; FN=FILENAME} # if a line starts with 120, increment RECords count, SUM field 26, keep filename
END {print FN";"REC";"SUM} #...
6,287
Posted By disedorgue
Ok, you can do it with awk as this example: $...
Ok, you can do it with awk as this example:
$ DATETIME="28-Sep-2013;20:09:08;"
$ CONTROL="AB"
$ echo "Myfile.txt|11671|7824.90|tttt|2822.48|xxx|yyy" | awk -F'|' -v d=$DATETIME -v c=$CONTROL...
6,287
Posted By RudiC
You don't need two awk cmds connected through a...
You don't need two awk cmds connected through a pipe; do it in one go:
awk -F'|' -v DT=$DATETIME -v CTL=$CONTROL 'BEGIN{OFS=";"} {print DT,$1,CTL,$11,$12,$16;}' $SUCCESSFILE
3,671
Posted By pamu
or with awk... awk -F "|"...
or with awk...

awk -F "|" 'NR==FNR{A[$1]=$0;next}{if(A[$1]){print A[$1]"|"$NF}}' file1 file2
3,671
Posted By Yoda
join -t"|" -1 1 -2 1 -o 1.1 1.2 2.2 file1...
join -t"|" -1 1 -2 1 -o 1.1 1.2 2.2 file1 file2
10,283
Posted By yinyuemi
awk -F'>|<' '/BILL_NO/{printf $3}/NAME\>/{print...
awk -F'>|<' '/BILL_NO/{printf $3}/NAME\>/{print NF==3?",NA":","$3}'
11,284
Posted By ghostdog74
awk -vvar=$VAR '{print var;print $0}' file
awk -vvar=$VAR '{print var;print $0}' file
11,284
Posted By Scrutinizer
Yeah that won't work... Try this then: sed "i\ ...
Yeah that won't work... Try this then:
sed "i\
$VAR" fileOr try ghostdogs' suggestion with double quotes:
awk -vvar="$VAR" '{print var;print $0}' infile
4,740
Posted By ghostdog74
won't work if there are strings like "nap", "NAG"...
won't work if there are strings like "nap", "NAG" etc.
4,740
Posted By yinyuemi
try: awk '{print (($0=="NA" ||...
try:

awk '{print (($0=="NA" || $0=="na")?$0:$0".txt")}' urfile
4,740
Posted By kurumi
$ ruby -ne 'chomp; print ($_ !~...
$ ruby -ne 'chomp; print ($_ !~ /^\s*(NA|na)\s*$/i ) ? $_+".txt\n": $_+"\n" ' file
4,740
Posted By ctsgnb
@Scruti, lol yes, it's better :D what is...
@Scruti,
lol yes, it's better :D

what is suppposed to happen if the file contain a line like

Na, i am not a line like the others !

??
4,740
Posted By Scrutinizer
sed '/^[Nn][Aa]/!s/$/.txt/' file
sed '/^[Nn][Aa]/!s/$/.txt/' file
4,740
Posted By yinyuemi
try awk '{print ($0~/^NA|na/?$0:$0".txt")}'...
try
awk '{print ($0~/^NA|na/?$0:$0".txt")}' urfile
4,740
Posted By Scrutinizer
awk '/^na|^NA/||$0=$0".txt"' file
awk '/^na|^NA/||$0=$0".txt"' file
4,740
Posted By ctsgnb
sed '/^[Nn][Aa]$/{p;d;};s/.*/&.txt/' infile
sed '/^[Nn][Aa]$/{p;d;};s/.*/&.txt/' infile
4,926
Posted By durden_tyler
Maybe something like this? $ $ #...
Maybe something like this?


$
$ # display the contents of the xml file
$ cat f1.xml
<INVOICES>
<INVOICE>
<NAME>Customer A</NAME>
<INVOICE_NO>1234</INVOICE_NO>
</INVOICE>
<INVOICE>...
4,926
Posted By fpmurphy
The Perl solution by durden_tyler is excellent...
The Perl solution by durden_tyler is excellent providing that the search term is not present in an unrelated element, i e.

<INVOICES>
<INVOICE>
<NAME>Customer A 2345</NAME>...
Showing results 1 to 24 of 24

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