Interpretation needed for gawk command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Interpretation needed for gawk command
# 1  
Old 11-23-2011
Interpretation needed for gawk command

Hi All

I am running a insatll script in linux which installs the project.
Could you please help in interpreting this command

Code:
gawk '{ if (substr($1,0,1) == "\047") gsub("^\047+|\047+$", "", $1); print }'
 
where $1 = BBME

Thanks
# 2  
Old 11-23-2011
It will remove single quotes at the beginning and end if found at the beginning of the string.
\047 = '

Code:
root@bt:/tmp# cat file
'BBME'

root@bt:/tmp# awk '{ if (substr($1,0,1) == "\047") gsub("^\047+|\047+$", "", $1); print }' file
BBME

HTH
--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Interpretation of UNIX command

what does the below do. echo * | xargs ls | wc –l echo * - Output a string comprising the name of each file in the working directory, with each name separated by a space. xargs ls - construct argument list command wc -l - it will pipe the output to the wc command, which will... (4 Replies)
Discussion started by: houmingc
4 Replies

2. AIX

Gawk command

Hello experts :) I have a question about Gawk command on AIX, could someone tell me the function of this command ? i have a script which has a gawk command : /usr/bin/xmllint --format /data/work/PROU/aggregates.flat.xml | gawk '! /<!--.*-->/ {print $0}' | gawk -f... (3 Replies)
Discussion started by: rimob
3 Replies

3. Shell Programming and Scripting

Command needed

Hi, I have the date as 20130101 and i need it to rephrased to 2013-01-01. Any command which can do this. (5 Replies)
Discussion started by: ATWC
5 Replies

4. Shell Programming and Scripting

Help with gawk command

Hi, I have a situation. in a particular file , from the 9th column i have to match a particular pattern . i want a second file which is made by excluding them. I wrote a code like this. gawk '$9~/^(SPI|OTC|SAX)$/' /home/ceh1/ceh_prod/plx_"$mydate"_old.tsv >>... (1 Reply)
Discussion started by: pranabrana
1 Replies

5. Windows & DOS: Issues & Discussions

Cannot run command line scripts in perl or gawk

I originally posted this to a different forum (I am a new Perl user) and realized the error so I will ask here. I am on a WindowsXP machine trying to run perl and gawk scripts from the command line. I have perl and gawk installed and environment set to C:\perl\bin and cannot get a script to... (2 Replies)
Discussion started by: 10000springs
2 Replies

6. AIX

methods of command interpretation in AIX

what are the various methods through which a command is interpreted in AIX? (1 Reply)
Discussion started by: AIXlearner
1 Replies

7. AIX

interpretation of sar

hello with a sar i have this result: System configuration: lcpu=48 ent=4.00 14:06:37 %usr %sys %wio %idle physc %entc 14:06:39 26 9 3 62 1.63 40.7 14:06:41 26 9 3 63 1.58 39.4 14:06:43 ... (0 Replies)
Discussion started by: pascalbout
0 Replies

8. UNIX for Advanced & Expert Users

SAR -b interpretation

I have used SAR -b to get some Unix cache / buffer metrics and the results are confusing me a bit. The pread/s & pwrit/s are showing 0. However the lread/s and lwrit/s are showing figures. I note also that the bread/s and bwrit/s are showing figures. I believe that pread/s and pwrit/s is not... (3 Replies)
Discussion started by: jimthompson
3 Replies

9. UNIX for Dummies Questions & Answers

Interpretation of the uptime command

Hi there, do someone have detailed information how to interpret the uptime command or rather which values can be called normal? (i know what the information means, but i have no idea if these values are ok or to high: 3:02pm an 13:53, 2 Benutzer, Durchschnittslast: 10,06, 12,05, 13,00) ... (5 Replies)
Discussion started by: odin1999
5 Replies

10. UNIX for Dummies Questions & Answers

shell interpretation

I executed the following command in the korn shell: $ variable1="qwerty" ls | sort and the shell executed the 'ls | sort' command. I would have expected an error message from the shell, but instead of that the shell ran the 'ls | sort' command and didn't realize the variable assignement. ... (1 Reply)
Discussion started by: PhilippeCrokaer
1 Replies
Login or Register to Ask a Question