10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
As per requirement if column 2 is NULL then 'N' ELSE 'Y'.
I have written below awk code. But it is not replacing values for first line. :confused:
cat temp.txt
1|abc|3
1||4
1|11|c
awk -F'|' '{if($2==""){$2="N"}else{$2="Y"} print $0 } {OFS="|"} ' < temp.txt
1 Y 3 ... (4 Replies)
Discussion started by: max_hammer
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
My input file gfile values is CTRY=GM&PROJTYPE=SP&PROJECTTYPE=Small+Project
If i am giving PROJECTTYPE then it must give Small Project
awk -F"&" '{for (i=1; i<=NF; i++) if ($i ~ "^"PAT) {sub ("^"PAT"=", "", $i); sed 's/'+'/""/' $i ; print $i }}' PAT=$1 ... (6 Replies)
Discussion started by: nag_sathi
6 Replies
4. UNIX for Dummies Questions & Answers
Hi all,
As of now am using an awk command to check the number of columns in a file that has 10 lakh rows.
Is it possible to remove that particular line having an extra column and copy the remaining lines to a new file ?
YOUR HELP IS HIGHLY APPRECIATED. THANKS IN ADVANCE (5 Replies)
Discussion started by: Rahul619
5 Replies
5. Shell Programming and Scripting
Can I use awk to search for a string, passed from the shell, that might include metacharacters?
File1 entries: Bob Marley Jammin (Bonus Track).mp3
File2 entries: Bob Marley Jammin (Bonus Track).mp3 32000 /Music/Bob Marley/ Jammin (Bonus Track).mp3
So far, I have this;
$ sed -e... (9 Replies)
Discussion started by: DSommers
9 Replies
6. Shell Programming and Scripting
I have a file which contains a list of paths separated by a new line character.
e.g
/some/path/to/a/file.png
/some/path to/another/file.jpeg
/some path/to yet/another/file
Notice that these paths may contain metacharacters, the spaces for example are also not escaped.
If I wanted... (5 Replies)
Discussion started by: cue
5 Replies
7. UNIX for Dummies Questions & Answers
Hi, Im trying to get current line in the AGREP command I use in AWK. My script looks like this:
list.txt
car
bus
checklist.txt
cer
buss
cat list.txt | awk -v mycmd="$(agrep -2 -i $0 checklist.txt)" '{print $mycmd}'
It doesnt work. How can I get the current line in the $0... (6 Replies)
Discussion started by: m4rty
6 Replies
8. UNIX for Dummies Questions & Answers
Hello. I am learning how to use Unix through an online course. Unfortunately the text that we use isn't very good, so I could use some help with a pretty basic question.
Use metacharacters and the ll command to list all filenames under the datafiles directory that contain a dot "." with the... (2 Replies)
Discussion started by: feverdream
2 Replies
9. Shell Programming and Scripting
Hi all,
I am new to awk.
I want to print the line numbers if the column has a particular value.
For example I have:
cat FILE1
COL1 COL2
X114 0
X116 0
X117 0
X120 0
X121 0
X125 0
X126 0
X127 0
X131 1
X132 0
X135 0
X136 0 (3 Replies)
Discussion started by: newpro
3 Replies
10. Shell Programming and Scripting
Hi ,
I have a piece of code ...wherein I need to assign the following ...
1) A command line argument to a variable
e.g origCount=ARGV
2) A unix command to a variable
e.g result=`wc -l testFile.txt`
in my awk shell script
When I do this :
print "origCount" origCount --> I get the... (0 Replies)
Discussion started by: sweta_doshi
0 Replies