Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: cdfd123
3,706
Posted By Yoda
awk '$3=="PCS000289"&&$1>3000{$3="YES"}1'...
awk '$3=="PCS000289"&&$1>3000{$3="YES"}1' file
75,931
Posted By Scrutinizer
@user8: not every awk retains the fields in the...
@user8: not every awk retains the fields in the END section. To get around this:
{s=$5} END{ print s }
75,931
Posted By user8
About how to print: "last row with fifth column;...
About how to print: "last row with fifth column; in each file":
END{ print $5 }or in case you are using gawk 4.x:
ENDFILE{ print $5 }
75,931
Posted By Don Cragun
First, please use CODE tags (not QUOTE tags) to...
First, please use CODE tags (not QUOTE tags) to show contents of files.

Second, we seem to have a language barrier. I do not understand what you want. Are you asking for a script that uses awk...
795
Posted By agama
You need to write the output to a tmp file and...
You need to write the output to a tmp file and then move it "over' the original file. You also want to ensure that the uniq command was successful before overlaying the bad/empty file on top of the...
1,942
Posted By ctsgnb
grep -f fileB fileA
grep -f fileB fileA
1,942
Posted By
>outputFile cat FileB | while read line do ...
>outputFile
cat FileB | while read line
do
grep "$line" FileA >> outputFile
done
780
Posted By ctsgnb
cut -c "$(cat fileB)" fileA
cut -c "$(cat fileB)" fileA
780
Posted By cabrao
awk -v v1=`cat file_b` '{print substr($1,v1,1)}'...
awk -v v1=`cat file_b` '{print substr($1,v1,1)}' file_a
1,058
Posted By pravin27
Something like this, #!/bin/sh while...
Something like this,


#!/bin/sh

while read line
do
ch=`echo $line | cut -c1`
number=`echo $line | cut -c2-`
awk '{print $2}' file1 | awk -v v1=$ch -v v2=$number -F"[A-Z]" '{for...
2,545
Posted By Klashxx
Another awk aprox: awk '{if (...
Another awk aprox:

awk '{if ( /"/){a=$1;b=$NF}else{$0=a""$0" "b}}1' file
2,545
Posted By summer_cherry
perl may help you
my ($a,$b);
while(<DATA>){
chomp;
if(/^(".*?").* (\S*)$/){
$a=$1;
$b=$2;
print $_,"\n";
}
else{
print $a," ",$_," ",$b,"\n";
}
}
__DATA__
"A" 2 aa 34
3 ac
...
2,545
Posted By zaxxon
With awk: awk 'NF==4 {a=$1; b=$4; print;...
With awk:

awk 'NF==4 {a=$1; b=$4; print; next} {print a, $0, b}' infile
"A" 2 aa 34
"A" 3 ac 34
"A" 5 cd 34
"B" 3 hu 67
"B" 4 fg 67
"B" 5 gy 67


If you...
2,545
Posted By guruprasadpr
Hi #awk...
Hi

#awk 'NF>2{a=$1;b=$4;$1=$1;print;next;}{$1=$1;print a,$0,b;}' file
"A" 2 aa 34
"A" 3 ac 34
"A" 5 cd 34
"B" 3 hu 67
"B" 4 fg 67
"B" 5 gy 67


Guru.
2,545
Posted By pravin27
something like this. previous_filed.pl ...
something like this.

previous_filed.pl

#!/usr/bin/perl

while (<>) {
if (/(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) {
$pr_1=$1;
$pr_4=$4;
...
1,691
Posted By ygemici
sed 's/\[/ \[/' al |sort -k4,1n -k1n >tmp ...
sed 's/\[/ \[/' al |sort -k4,1n -k1n >tmp
IFS=$'\n'
for i in `cat tmp | cut -d"]" -f1 | sed 's/.*\[\(\.*\)/\1/'|uniq|sort`
do
sed "/$i/!d" tmp | sed -n '$p;s/ \[/[/'
done
100 ...
1,691
Posted By guruprasadpr
Hi # sed 's/\]/\[/' file | sort -t"[" -k2,2...
Hi

# sed 's/\]/\[/' file | sort -t"[" -k2,2 -k 1nr | awk -F"[" '!a[$2]++' | sed 's/\[/\]/2'
100 >aa[John 2] >abc[John 2] >bca[John 2]
87 >def[Mona 3.1] >fgh[Mona 3.1] <ijk [Mona 3.1]
89 ...
1,271
Posted By zaxxon
$> awk '$2==a && $3==b {print; next} {i++;...
$> awk '$2==a && $3==b {print; next} {i++; if(NR==1){print "file A-"i}else{print "\nfile A-"i}; a=$2; b=$3; print}' infile
file A-1
aa 22 48
ab 22 48

file A-2
tcf 50 76
gf 50 76

file...
2,942
Posted By Scott
$ sed "s/[A-Z][A-Z]*/ & /g" file1 | awk '{print...
$ sed "s/[A-Z][A-Z]*/ & /g" file1 | awk '{print $1 $2-$4+2 $3}'
1,949
Posted By guruprasadpr
Hi If the order of the result is not a concern...
Hi
If the order of the result is not a concern for you, try this:


awk 'NR==FNR{a[i++]=$0;next;}{for(j in a){x=a[j];gsub(/[A-Z]/,"",x);x=int(x);if ($1<x && $2>x) print a[j],$0;}}' i=1 fileA...
1,757
Posted By summer_cherry
my...
my %hash=(A,1,C,2,D,3,E,4,F,5,G,6,H,7,I,8,K,9,L,10,M,11,N,12,P,13,Q,14,R,15,S,16,T,17,V,18,W,19,Y,20);
open $fh,"<","a.spl";
my %hash1;
while(<$fh>){
my @tmp=split(/\*/,$_);
for(my...
Showing results 1 to 21 of 21

 

Featured Tech Videos

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