10 More Discussions You Might Find Interesting
1. Homework & Coursework Questions
hi gurus,
I am not sure what the below commands does.
awk 'BEGIN {sum=0} {sum=sum+$5} END {print sum}' input_file (4 Replies)
Discussion started by: ramkumar15
4 Replies
2. Shell Programming and Scripting
Hi,
I am trying to pass awk field to a command line executed within awk (need to convert a timestamp into formatted date).
All my attempts failed this far.
Here's an example.
It works fine with timestamp hard-codded into the command
echo "1381653229 something" |awk 'BEGIN{cmd="date -d... (4 Replies)
Discussion started by: tuxer
4 Replies
3. Shell Programming and Scripting
Hi Experts,
I am trying to get system output to capture inside awk , but not working:
Please advise if this is possible :
I am trying something like this but not working, the output is coming wrong:
echo "" | awk '{d=system ("date") ; print "Current date is:" , d }'
Thanks, (5 Replies)
Discussion started by: rveri
5 Replies
4. Shell Programming and Scripting
below is the output xml string from some other command and i will be parsing it using awk
cat /tmp/alerts.xml
<Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies
5. Shell Programming and Scripting
Hi,
I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files.
To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Discussion started by: anandek
10 Replies
6. Shell Programming and Scripting
Hi,
I am using below awk code to convert a csv file data into fixed file format.
awk 'BEGIN { FS = ","
fmt = "%10s%010d%10s%d%1d\n" }
NR>1 { printf fmt, $1, $2, $3, $4*100, $5 }' /data/mydata.csv > /data/fixed.dat
Data in mydata.csv
================... (2 Replies)
Discussion started by: kbmkris
2 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I am using below awk code to convert a csv file data into fixed file format.
awk 'BEGIN { FS = ","
fmt = "%10s%010d%10s%d%1d\n" }
NR>1 { printf fmt, $1, $2, $3, $4*100, $5 }' /data/mydata.csv > /data/fixed.dat
Data in mydata.csv
================... (1 Reply)
Discussion started by: kbmkris
1 Replies
8. Shell Programming and Scripting
Hello all,
Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val:
> cat getnon0file.sh
#!/bin/bash
this="getnon0file.sh"
USAGE=$this"
InFile="xyz.38"
Min="0.05"
#
awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies
9. UNIX for Dummies Questions & Answers
Hello!
I have written this script:
for file in "$( find $dirName -type d )"
do
echo "$file"
echo "hello"
done
but as a result I get all the directories and in the end the work "hello". Shouldn't it print the word "hello" after printing the name of each directory and not in the end?
... (1 Reply)
Discussion started by: GeorgeP
1 Replies
10. UNIX for Dummies Questions & Answers
I have a script problem that I am not able to solve due my very limited understanding of unix/awk.
This is the contents of test.sh
awk '{print $1}'
From the prompt if I enter:
./test.sh Hello World
I would expect to see "Hello" but all I get is a blank line. Only then if I enter "Hello... (2 Replies)
Discussion started by: JasonHamm
2 Replies