Search Results

Search: Posts Made By: i150371485
1,607
Posted By nua7
awk comparision between 2 files and substitution in third
Hi All,
I have two files in the following format.

File 1 :

1044|1|20121031|2910039.4|MR|201210|G1044|E
1082|2|20121031|1664662.84|MR|201210|G1082|E
1696|3|20121031|190801.5|MR|201210|G1696|E...
1,607
Posted By rangarasan
awk
Hey,

Try sth like this,


awk -F'\|' 'FNR==NR{a[$1]= $2"^"$3;next;}a[$2]{split(a[$2],b,"^");$6=b[1];$14=b[2];}1' OFS="|" file1 file2


Cheers,
Ranga:)
1,607
Posted By Scrutinizer
Small variation with two single arrays: awk...
Small variation with two single arrays:
awk 'NR==FNR{A[$1]=$3; B[$1]=$2; next} $2 in A{$6=B[$2]; $14=A[$2]}1' FS=\| OFS=\| file1 file2
1,607
Posted By Yoda
An approach using join join -t"|" -1 2 -2 1 -o...
An approach using join
join -t"|" -1 2 -2 1 -o 1.1 1.2 1.3 1.4 1.5 2.2 1.7 1.8 1.9 1.10 1.11 1.12 1.13 2.3 1.15 1.16 1.17 1.18 file2 file1
1,607
Posted By Scrutinizer
Sure: awk ' NR==FNR{ ...
Sure:

awk '
NR==FNR{ # When the first file is being read (only then are FNR and NR equal)
A[$1]=$3 # create an (associative) element in array A...
1,410
Posted By durden_tyler
The regex does not match this data either. ...
The regex does not match this data either.


$
$ cat f77
000800 15 test1 PIC X
000800 15 test1 PIC XX
000800 15 test1 PIC XXX
000800 15 test1 PIC X(8)
000800 15 test1 PIC X(12)
000800 15...
1,410
Posted By Scrutinizer
That regex does not match any of lines in the...
That regex does not match any of lines in the input file.
2,801
Posted By zazzybob
Hi, Moving a text file just renames the text...
Hi,

Moving a text file just renames the text file - no conversion is happening.

You'll need to consult the tools available on your system - for example on most modern Linux systems you can use...
1,094
Posted By balajesuri
echo "ABC_HYND_JDHD_20130125120345.txt" | sed...
echo "ABC_HYND_JDHD_20130125120345.txt" | sed 's/[0-9]\{6\}\.txt/.txt/'
or
echo ${filename/[0-9][0-9][0-9][0-9][0-9][0-9].txt/.txt}
1,094
Posted By itkamaraj
$ echo $filename | nawk -v OFS=_ -F_...
$ echo $filename | nawk -v OFS=_ -F_ '$NF=substr($NF,1,8)".txt"'
ABC_HYND_JDHD_20130125.txt
2,395
Posted By Scrutinizer
OK: awk ' NR==FNR{ ...
OK:

awk '
NR==FNR{ # while reading the first file
for(i=2; i<=NF; i++) A[$1,i]=$i # record every field and tie it to the value of the...
2,395
Posted By Scrutinizer
What have you tried so far, what was your idea?
What have you tried so far, what was your idea?
2,395
Posted By Scrutinizer
OK, have a try with pseudo-multidimensional...
OK, have a try with pseudo-multidimensional arrays in awk:
awk 'NR==FNR{for(i=2; i<=NF; i++) A[$1,i]=$i; next} {for(i=2; i<=NF; i++) if($i=="") $i=A[$1,i]}1' FS=\| OFS=\| file1 file2
1,355
Posted By itkamaraj
$ nawk 'NR%3!=0{printf("%s...
$ nawk 'NR%3!=0{printf("%s ",substr($0,2,length))}NR%3==0{printf("%s\n",substr($0,2,length))}' input.txt
001 jkilo yrhfm 00056 jhdf rjhwjkrh +u8jk5h3 uru ehjk
002 jkfhk hfjkd 748395 fdjksfh...
2,192
Posted By Scrutinizer
Hi, if there is a match that involves: group 1:...
Hi, if there is a match that involves:
group 1: the beginning of a line(^) or a field separator (\|), followed by
group 2: 1 or more numbers or dots, followed by
a dot(\.), followed by
group 3:...
2,192
Posted By Scrutinizer
See if this works: perl -pe...
See if this works:
perl -pe 's/(^|(?<=\|))([0-9.]+)\.(\||$)/$2$3/g' file
2,192
Posted By pamu
Try perl -pe 's/\.\|/\|/g' file ...
Try

perl -pe 's/\.\|/\|/g' file
100000||1925-01-10|00:00|1862SHERMA NAVE#1SE||EVTON|IL|60201||22509|BDSS|62007|2639|26670
100001||1935-01-10|00:00|1862NEW . YRK...
1,733
Posted By danielos
I propose you a solution, maybe it is not the...
I propose you a solution, maybe it is not the best one but you have to correct a bit of code but it works.


awk '$0 ~ /\(/, $0 ~ /PRIMARY/ {print $1,$2}' kk | while read var tipo
do ...
1,570
Posted By elixir_sinari
Assuming that there are no tabs to be removed: ...
Assuming that there are no tabs to be removed:
sed '/^ *$/d;s/ *| */|/g' file
1,570
Posted By itkamaraj
$ sed 's/ *|/|/g;s/| */|/g' file1.txt ...
$ sed 's/ *|/|/g;s/| */|/g' file1.txt
1|a|4757634|jund jdkj|erhyj
2|a|4757634|jnd jdkj|rhje hjrhwj
1,016
Posted By complex.invoke
sed...
sed 's!\(.\{5\}\)\(.\{4\}\)\(.\)\(.\{4\}\)\(.\{2\}\)\(.\)\(.*\)!\1|\2|\3|\4|\5|\6!g' infile
1,016
Posted By pamu
try $ cat file 12345JackYKing32N 1235...
try

$ cat file
12345JackYKing32N
1235 JulyYoig 31N

$ awk -v var="5,4,1,4,2,1" '{n=split(var,P,",");k=1;for(i=1;i<=n;i++){s=s?s"|"substr($0,k,P[i]):substr($0,1,P[i]);k+=P[i]}print s;s=""}'...
1,374
Posted By pamu
s=s?s","i:i # Here we assign values to s....
s=s?s","i:i # Here we assign values to s. First here it checks s presents or not

s? --> Is s present? If present then do the true part else do the false part. see below.

s?True:FalseAssume...
1,374
Posted By pamu
awk -F "|" '{ for(i=1;i<=NF;i++){if($i ~...
awk -F "|" '{ for(i=1;i<=NF;i++){if($i ~ /[0-9]\.[0-9]/){s=s?s","i:i}}print s;s=""}' file
1,194
Posted By pamu
This is my script. name is test.sh $ cat...
This is my script. name is test.sh

$ cat test.sh
file=$1 #file name
FIR=$2 # first field to print
FILD=$3 # Number of fields

awk -v first="$FIR" -v Field="$FILD" -F "|" '{ s=$first;...
Showing results 1 to 25 of 69

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