Search Results

Search: Posts Made By: CAch
2,618
Posted By RudiC
Very good, congrats! You may want to have...
Very good, congrats!
You may want to have string fields left justified; then, use a minus sign: "%-4s".
2,618
Posted By RudiC
That's because awk treats any number of spaces as...
That's because awk treats any number of spaces as field separator (unless told otherwise). As you can see, the formatting has already gone in the first action's output. If you need exactly formatted...
Forum: Red Hat 07-11-2013
3,733
Posted By Skrynesaver
Try logging in to a pseudo terminal, or via ssh...
Try logging in to a pseudo terminal, or via ssh to the VM, then post the output of ls -l /home and df -h
3,791
Posted By pravin27
awk '{if (j==0){j++;print;next} for...
awk '{if (j==0){j++;print;next}
for (i=1;i<=NF;i++) {
sum+=$i;
}
j++;
if (j == 21){$21=sum;j=0;sum=0}
print $0}' MatrixFile
2,297
Posted By Yoda
I noticed some inconsistencies in your...
I noticed some inconsistencies in your requirement!

If you want to split each alpha-numeric string greater than 3 character length, then why the following highlighted 4 character length string is...
877
Posted By Scrutinizer
Try something like this: awk '/^HUMAN/{print >...
Try something like this:
awk '/^HUMAN/{print > ( "set_" $3 )}' file
1,053
Posted By RudiC
Hey, come on, be reasonable, and be creative. If...
Hey, come on, be reasonable, and be creative. If you want to print "with", embed "with" into the text.
And, for "last underscore", man bash:
1,053
Posted By RudiC
Try also:$ echo filename is ${f%_*} serial no....
Try also:$ echo filename is ${f%_*} serial no. ${f#*_} | cat - $f
1,053
Posted By balajesuri
#! /bin/bash f="asdf_432" x=${f%_*} ...
#! /bin/bash

f="asdf_432"
x=${f%_*}
y=${f#*_}

sed -i.bak "1i filename is $x serial no. $y" $f
2,642
Posted By PikK45
Try this, echo "assa dsad werr vdss a.txt...
Try this,

echo "assa dsad werr vdss a.txt is 2.4
assa dsad werr vdss b.txt is 3.2
assa dsad werr vdss c.txt is 4.3" | eval mv `awk '{f=$5; sub(/.txt/,"",$5); print f" "$5"_"$7; }'`

This...
2,642
Posted By balajesuri
The solution in post #2 works for me on my...
The solution in post #2 works for me on my GNU/Linux running bash 4.1.10.
Could you please post the output of uname -a and bash --version
2,642
Posted By balajesuri
#! /bin/bash while read v1 v2 v3 v4 v5 v6 v7 ...
#! /bin/bash
while read v1 v2 v3 v4 v5 v6 v7
do
[ -e $v5 ] && mv "$v5" "${v5%.txt}_$v7"
done < filenamelist.txt
1,764
Posted By vgersh99
nawk 'FNR==NR {f1[$2]=$0;next}{print ($1 in...
nawk 'FNR==NR {f1[$2]=$0;next}{print ($1 in f1)?f1[$1]:"ABSENT"}' firstFile secondFile
1,764
Posted By danmero
awk 'NR==FNR{a[$2]=$0;next}{print...
awk 'NR==FNR{a[$2]=$0;next}{print a[$1]?a[$1]:"ABSENT"}' file1 file2
1 a rew sdf ghd 234 gfd 345
ABSENT
7 c dns esd lkn 765 nkc 093
4 d bhj asd klj 231 kljn 211
ABSENT
3 f hjk kln ghj 879 nkj...
1,052
Posted By DGPickett
Well, use shell or awk, not both. sed ' ...
Well, use shell or awk, not both.

sed '
/^[0-9]* PRO /!d
s/.* //
' your_file |sort -nu | read key5

grep "^[0-9]* PRO .* $key5$" your_file


The file name of a list of file names...
1,052
Posted By bartus11
Try: awk...
Try: awk '!a[$2]{a[$2]=$0;m[$2]=$5}$5<m[$2]{a[$2]=$0;m[$2]=$5}END{for (i in a) print a[i]}' file
5,977
Posted By Corona688
I think I get it... awk -v DATA1="datafile1"...
I think I get it...

awk -v DATA1="datafile1" 'BEGIN {
COMPLETE=1
# Read lines like 'fds 21 sdf 32 6432', so A["21"]="6432" etc.
while(getline <DATA1)
{
...
5,977
Posted By bartus11
Try:awk 'NR==FNR{a[$1]=$5;next}{print...
Try:awk 'NR==FNR{a[$1]=$5;next}{print a[$0]?a[$0]:"ABSENT"}' file1 file2
1,236
Posted By bartus11
Try: awk...
Try: awk '{if(m[$1]>$5||a[$1]==""){a[$1]=$0;m[$1]=$5}}END{for (i in a){print a[i]}}' file
PS. for your sample data, correct output seems to be:9 ALA 9 ALA 0.00000
16 ALA 16 ALA 0.000000
4,445
Posted By mirni
No need for 'paste'; that tool is used to merge...
No need for 'paste'; that tool is used to merge lines. I assume the file liist has the filenames to be processed, one per line, right?
The redirection operator you have there, '>' will truncate the...
4,445
Posted By mirni
Put your strings ALA, ASD, etc all in one file,...
Put your strings ALA, ASD, etc all in one file, one per line. Let's call this file 'strings'.
Then you can do:

while read aa ; do
awk '$2=="'$aa'" && !($1==$3 && $5==0){print}' input | sort...
5,302
Posted By ygemici
hmm lets try this:) paste list1 list2|while...
hmm lets try this:)
paste list1 list2|while read f1 f2 ; do
for string in ALA VAL #-> (20 strings will be here)
do awk 'NR==1{s=$20;next}$5==s&&$2=="'$string'"{a[i++]=$4};...
5,302
Posted By ygemici
Hi,you can try this.. paste list1 list2 | while...
Hi,you can try this..
paste list1 list2 | while read f1 f2;do
awk 'NR==FNR{a[$20]=$20;b=$4;next}a[$5]{print b"\t"$4}' $f1 $f2;done


regards
ygemici
5,302
Posted By mirni
ummm... sorry I forgot a redirection operator: ...
ummm... sorry I forgot a redirection operator:
while read f1 f2 ; do
awk 'NR==1{s=$1; next} $2=="ALA" && $5==s {print $4} ' $f1 $f2
done < <(paste list1 List2)

or, in a more concise way:...
Showing results 1 to 24 of 24

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