10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have the following awk script that I am using to find the max value in the file and print results.
awk 'BEGIN {MAX=-1E100} {for (x=2; x<=NF; x++) if ($x>MAX) {MAX = $x; C1 = $1}} END {print substr(C1,1,11), substr(C1,13,4), substr(C1,18,2), MAX}' ABC*
Input (ABC*)
... (6 Replies)
Discussion started by: ncwxpanther
6 Replies
2. Shell Programming and Scripting
Hello,
I am new to awk and I am trying to figure out how to print an output based on user input.
For example:
ubuntu:~/scripts$ steps="step1, step2, step3"
ubuntu:~/scripts$ echo $steps
step1, step2, step3
I am playing around and I got this pattern that I want:
... (3 Replies)
Discussion started by: tattoostreet
3 Replies
3. Shell Programming and Scripting
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies
4. Shell Programming and Scripting
I would like to print the number of records of 2 files, and divide the two numbers
awk '{print NR}' file1 > output1
awk '{print NR}' file2 > output2
paste output1 output2 > output
awl '{print $1/$2}' output > output_2
is there a faster way? (8 Replies)
Discussion started by: programmerc
8 Replies
5. Shell Programming and Scripting
Is it possible to print max number of 2 columns - awk
note: print max if the integer is positive and print min if the integer is negative
input
a 1 2
b 3 4
c 5 1
d -3 -5
d -5 -3
output
a 2
b 4
c 5
d -5
d -5 (4 Replies)
Discussion started by: quincyjones
4 Replies
6. Shell Programming and Scripting
hi guys,
i have the following problem: i have a matrix with 3 columns and over 450 rows like this:
0.0165 0.0151 0.0230
0.0143 0.0153 0.0134
0.0135 0.0123 0.0195
0.0173 0.0153 0.0182
i now want to calculate the average of every line and divide every element of this... (1 Reply)
Discussion started by: waddle
1 Replies
7. Shell Programming and Scripting
Dear all,
I have to transform a bunch of files into a new format. how to do it with bash script, especially with 'awk' command.
the original data
O,0,0.2839896442,-1.1628392411,-1.5976515479
Cr,0,-0.0502858628,-0.1725974837,-0.380627632
C,0,2.4506658279,-0.476964918,0.2299298249
... (3 Replies)
Discussion started by: liuzhencc
3 Replies
8. Shell Programming and Scripting
Hi,
I need help in printing out the dates with the largest value in front of it using awk.
436 28/Feb/2008
436 27/Feb/2008
436 20/Feb/2008
422 13/Feb/2008
420 23/Feb/2008
409 21/Feb/2008
402 26/Feb/2008
381 22/Feb/2008
374 24/Feb/2008
360... (7 Replies)
Discussion started by: SIFA
7 Replies
9. Shell Programming and Scripting
Hello there.
I want some help with awk
I have this script that reads a file from awk and you can insert from keyboard any list from the fields that exist so to be printed on monitor
echo "give a choice"
read -a ans
array=${ans}
awk -F: -v k="$array" '{
... (4 Replies)
Discussion started by: covis
4 Replies
10. Shell Programming and Scripting
Can some body tell me how to print number of line from a particular file, with sed. ?
Input file format
AAAA
BBBB
CCCC
SDFFF
DDDD
DDDD
Command to print line 2 and 3 ?
BBBB
CCCC
And also please tell me how to assign column sum to variable.
I user the following command it... (1 Reply)
Discussion started by: maheshsri
1 Replies