Search Results

Search: Posts Made By: rpf
1,007
Posted By RudiC
Pls use code tags as advised. As you do not...
Pls use code tags as advised.
As you do not specify any rule on how to combine the files, I just guessed it should be $1, $2 from file1, and $2, $3 from file2, per line no. Try $ awk 'NR==FNR...
1,203
Posted By Yoda
You have to change 2nd line to: NF==3 {...
You have to change 2nd line to:
NF==3 { for(i=1;i<=NF;i++) { sum+=($i*$i); } if(NR==1) printf "%s\n", sqrt(sum); else printf "\n%s\n", sqrt(sum); sum=0;}
1,203
Posted By Yoda
Assuming every new set starts with 3 numbers:- ...
Assuming every new set starts with 3 numbers:-
awk ' BEGIN { sum=0; }
NF==3 { for(i=1;i<=NF;i++) { sum+=$i; } if(NR==1) printf "%s\n", sum; else printf "\n%s\n", sum; sum=0;}
NF>3 {...
1,203
Posted By Yoda
awk ' BEGIN { sum=0; } NR==1 {...
awk ' BEGIN { sum=0; }
NR==1 { for(i=1;i<=NF;i++) { sum+=$i; } print sum; }
NR>1 { for(i=1;i<=NF;i++) printf "%s ", $i }
END { printf "\n";
} ' filename
1,239
Posted By bmk
Try like... awk -F '|' '{s+=$2} END {print...
Try like...

awk -F '|' '{s+=$2} END {print s}' test1.txt
1,239
Posted By ygemici
# awk '!/^ *$/{a+=$2;x++}END{print a/x}' infile
# awk '!/^ *$/{a+=$2;x++}END{print a/x}' infile
1,239
Posted By itkamaraj
average awk '/./{a+=$2;x++}END{print a/x}'...
average

awk '/./{a+=$2;x++}END{print a/x}' infile
1,239
Posted By ygemici
summary # awk '{a+=$2}END{print a}' infile ...
summary
# awk '{a+=$2}END{print a}' infile
average
# awk '{a+=$2;x++}END{print a/x}' infile
1,899
Posted By complex.invoke
why don't use the shell builtin feature for...
why don't use the shell builtin feature

for FILE in file*; do
mv ${FILE} file-${FILE//[^0-9]/}
done
1,899
Posted By radoulov
And another one: for f in file*.dat; do ...
And another one:

for f in file*.dat; do
_f=${f%.dat}
mv -- "$f" "${_f/file/file-}"
done The /pattern/substitution/ parameter expansion
is not standard/POSIX (it's supported by most modern...
1,899
Posted By Scrutinizer
@rpf, if you use the suggestion with IFS, don't...
@rpf, if you use the suggestion with IFS, don't forget to put IFS back to its original value if you plan to do more stuff in the same shell, otherwise you will get unexpected results...
1,899
Posted By Corona688
Sure. #!/bin/bash # Make variable...
Sure.

#!/bin/bash

# Make variable splitting happen on "."
IFS="."

for FILE in file*
do
# Set $1="filename", $2="ext", because it splits on "."
set -- $FILE

...
1,899
Posted By Corona688
#!/bin/bash for FILE in file* do ...
#!/bin/bash

for FILE in file*
do
echo mv "$FILE" file-"${FILE:4}"
done

Remove the echo once you've tested and are sure it does what you want.
1,899
Posted By 47shailesh
for file in `ls file*`; do mv $file `echo...
for file in `ls file*`;
do
mv $file `echo $file | sed s:file:file-:`
done
14,887
Posted By Scrutinizer
If there are not too many files: awk...
If there are not too many files:
awk 'FNR==1{if(f)print f;f=x} $0~s{f=$0} END{if(f)print f}' s=energy text*
14,887
Posted By CarloM
for filename in text*; do grep 'energy' $filename...
for filename in text*; do grep 'energy' $filename | tail -1; done
14,887
Posted By CarloM
I didn't mean using tail on its own. What you...
I didn't mean using tail on its own. What you want is something like:
grep something wherever | tail -1
'|' is a pipe - the output from grep is being fed into tail.
2,641
Posted By palanisvr
Try this
cat file.txt |tr ',' '\n' | tr -d ' '
2,641
Posted By tarun_agrawal
tr ',' '\n' < filename
tr ',' '\n' < filename
2,641
Posted By bartus11
sed 's/, /\n/g' file
sed 's/, /\n/g' file
1,286
Posted By MacMonster
The triangle is 3D? Your coordinates have z-axis...
The triangle is 3D? Your coordinates have z-axis (x, y, z).
1,304
Posted By amitranjansahu
use -w option for whole word search ...
use -w option for whole word search


grep -w 275 myfile.txt


check man page of grep for more details
1,304
Posted By ahamed101
grep -w '275' myfile.txt man grep ...
grep -w '275' myfile.txt


man grep

--ahamed
1,845
Posted By Shell_Life
echo...
echo 'fish://ulavet@rits1.ula.com.tr/home_put1/bidds/myfo' | sed 's#.*//[^/]*/#/#'
1,845
Posted By zaxxon
You got a similar request in your other thread...
You got a similar request in your other thread https://www.unix.com/shell-programming-scripting/170206-using-part-line-variable-3.html where nobody answered anymore. Please keep to that thread and do...
Showing results 1 to 25 of 47

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