awk command format ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk command format ?
# 1  
Old 11-14-2005
awk command format ?

Can some body tell me the meaning of '$1=$1' in the following syntax.

nawk -v RS='' -v OFS=',' '$1=$1' myFile.txt


Thanks,
Mahesh Smilie
# 2  
Old 05-05-2009
Need clarification

Hi,

Could anybody explain me the peice of code below as well:
filecount()
{
[ -e "$1" ] && numfiles=$# || numfiles=0
}
# 3  
Old 05-05-2009
Quote:
Originally Posted by rjanardhan83
Hi,

Could anybody explain me the peice of code below as well:
filecount()
{
[ -e "$1" ] && numfiles=$# || numfiles=0
}
If the pass filename exists then set numfiles to the no of arguments passed
if not, the set numfiles to 0.

cheers,
Devaraj Takhellambam
# 4  
Old 05-06-2009
Quote:
Originally Posted by devtakh
If the pass filename exists then set numfiles to the no of arguments passed
if not, the set numfiles to 0.

cheers,
Devaraj Takhellambam


Hi,

Thank you so much for the help.Could you also please elaborate what is meant by [ -e "$1"]...

rgrds,
janardhan
# 5  
Old 05-06-2009
Power This should help your cause

Here, [ -e var1 ] is used here to check for the existence of that variable
( var1), In your case its,$1 , which signifies the first argument bring passed to the script.


I hope this suffices the question..Smilie

Regards,

Last edited by abhisek.says; 05-06-2009 at 09:32 AM.. Reason: Spelling change
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed/awk command to convert number occurances into date format and club a set of lines

Hi, I have been stuck in this requirement where my file contains the below format. 20150812170500846959990854-25383-8.0.0 "ABC Report" hp96880 "4952" 20150812170501846959990854-25383-8.0.0 End of run 20150812060132846959990854-20495-8.0.0 "XYZ Report" vg76452 "1006962188"... (6 Replies)
Discussion started by: Chinmaya Kabi
6 Replies

2. Shell Programming and Scripting

awk Format

Guys ,, pls .. need help with this ... File 1 0A6C Not Visible ???:? NA:NA TDEV N/Grp'd NR 5121 0A6D Not Visible ***:* NA:NA TDEV N/Grp'd RW 33784 0A6E Not Visible ***:* NA:NA TDEV N/Grp'd RW 33784... (4 Replies)
Discussion started by: greycells
4 Replies

3. Shell Programming and Scripting

Format output in AWK command

hi Friends , I have a file as below s.txt 1~2~~4 2~6~~7 3~8~~9 t.txt 1~2~~4 2~5~8~7 3~8~~7 header for both files is common (2 Replies)
Discussion started by: i150371485
2 Replies

4. Shell Programming and Scripting

a cut-command or special format pattern in awk

Hi i read data with awk, 01.07.2012 00:10 227.72 247.50 1.227 1.727 17.273 01.07.2012 00:20 237.12 221.19 2.108 2.548 17.367 01.07.2012 00:30 230.38 230.34 3.216 3.755 17.412 01.07.2012 00:40 243.18 242.91 4.662 5.172 17.328 01.07.2012 00:50 245.58 245.41 5.179 5.721 17.128... (3 Replies)
Discussion started by: IMPe
3 Replies

5. Shell Programming and Scripting

Format using AWK

Need some help .. in formating some input INPUT FILE IMAGE ap00m43 0 0 8 ap00m43_1318914034 UNIX_STANDARD_ADC_2 0 *NULL* root Daily 1 0 1318914034 408 1319518834 0 HISTO -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 FRAG 1 1 0 0 2 20 6 G11890 ts00p71 65536 FRAG 1 2 13440 0 2 20 7 G11890 ts00p71... (2 Replies)
Discussion started by: greycells
2 Replies

6. Shell Programming and Scripting

Format in AWK please

Am new to AWk, Can anyone help me to get excepected output from given input please. input file student: name details of them = details_needed class: 5th_needed adress: address_needed Expected output: details of them = 5th_needed = address_needed ---------- Post updated at... (5 Replies)
Discussion started by: Elavarasan
5 Replies

7. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

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

8. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

9. Shell Programming and Scripting

Format Output with AWK command

Hi - I have a file with contents as below. 12.1 a.txt 12.1 b.txt 12.1 c.txt 13.2 a.txt 13.2 d.txt 14.3 f.txt 15.4 a.txt 15.4 b.txt 15.4 z.txt I need to print the contents like this. 12.1 a.txt <&nbsp><&nbsp><&nbsp>b.txt <&nbsp><&nbsp><&nbsp>c.txt (7 Replies)
Discussion started by: guruparan18
7 Replies

10. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies
Login or Register to Ask a Question