Awk display


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Awk display
# 1  
Old 05-15-2009
Awk display

Hi All,

I got a script like

Code:
#!/bin/ksh
echo "Welcome Sir"|awk '
{
      print $1
}'

This is printing Welcome. I want output like 'Welcome' enclosing by single quotes.

Please assist me.

Thanks,
Shahnaz.
# 2  
Old 05-15-2009
This little script may do the trick:

Code:
 
#!/bin/bash 
hi=`echo "welcome sir" | awk '{print $1}'`; echo "'"$hi"'"

# 3  
Old 05-15-2009
Probably this would work:--
#!/bin/ksh
echo "Welcome Sir"|awk '{print \'$1\'}'
# 4  
Old 05-15-2009
Thanks all for your valuable solutions.

I tried the following it worked for me.

Code:
#!/bin/ksh
# ' means interpretter on in awk terminology
echo "welcome to my home"|awk '
{
        print "'\''"$1"'\''"
}'

' is interpretter on/off in awk terminology...

Thanks,
Shahnaz.
# 5  
Old 05-15-2009
MySQL Awk display

HI,
This is my first reply unix forum,

please try this,

echo "'welcome' sir" | awk '{print $1}'

o/p is 'welcome'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk command to display particular pattern

Hi I am using awk to print 10,11 column but it is not displaying required output. Please let me know how I can browse through the line and extract the required one Example: I have below 2 lines in file seq 49960| Thu Apr 19 10:57:40.726182 2018|Len: 89|GAP for CL/U18 9P-NC (CL90U8)) gap... (10 Replies)
Discussion started by: sdosanjh
10 Replies

2. Shell Programming and Scripting

Display the file name on each line using awk

How do I display the filename that has been awk to each of the line in Unix, i need to so far I have tried {print FILENAME;nextfile} but to no avail. `awk -F, '/1.2 Install TCP Wrappers/ {P=0} /1.1 Apply latest OS patches/ {P=1} P' solarisappsummary.txt solarisdbsummary.txt` For... (6 Replies)
Discussion started by: alvinoo
6 Replies

3. Shell Programming and Scripting

Grep awk sed display value

Hello all, I wget a file and i tried to display some value : content=$(wget IP:9005/GlobalStatistics -q -O -) echo onlineusers $content > /home/active_session_log #cat active_session_log {"ActiveSessionCount":0,"ActiveGameCount":0,"QueueMatchMakingPlayerCount":0} My goal is write... (7 Replies)
Discussion started by: acidozik
7 Replies

4. Shell Programming and Scripting

Awk to display lines that contain a period only in the first column

I've been trying to figure this out for quite a bit... I'm trying to check the first column for a period and only display the line if it contains a period. Below is a sample of the data i'm working with. www.homestorest 7200 IN CNAME www.homestorest.fishing.net.shopit.net.... (6 Replies)
Discussion started by: spartan22
6 Replies

5. Shell Programming and Scripting

how to display some special results with AWK

I have a file like this: AAEQGAGNQPQH,,,,160,32,,,, AAGQDYNSPLH,,712,39,,,,,, AAGREGGNTEAF,26,,,,,,,,4 AAGSPQH,,,,8,5,,,, AAKKLGQFYNEQF,4,,6,,,7,,,2 AANSGGRYNEQF,,2747,3120,,,,,, AAQGGVGGELF,,,,5,,12,36,, AAQGLAGYYEQY,,25,13,,,,,, AAQRGNEQF,510,2,,,6,,6,,76 AAQTGENSPLH,,16,16,,,,,, The... (9 Replies)
Discussion started by: xshang
9 Replies

6. Shell Programming and Scripting

a little help with using AWK to display whats being read in

I am making a script that reads in the model of a car and then searches a file and displays the make model and price of anything matching the input provided. here is what I have so far #!/bin/sh echo Please enter a car model: read model if test $? -eq 0 then grep $model /home/cars awk... (4 Replies)
Discussion started by: subway69
4 Replies

7. Shell Programming and Scripting

awk & display on one line

awk '/description/ || /instances/ {print;getline;print}' rtprod2.scp This command gives me something like below. description=OpsExec_Clinical instances=0 description=OpsExec_Pharmacy instances=1 description= instances=0 description= instances=0 description= description=OP_MVOR_ORU_OUT... (9 Replies)
Discussion started by: Daniel Gate
9 Replies

8. Shell Programming and Scripting

syslog grep/awk/sed display

What i am trying to do is pull all the "fail" and "error" from the HP-UX syslog except if it includes "sshd" or "ftpd" and IF the next line says "above message repeats NN time" display the next line. Got some of it working with someones help with sed but Im more familiare with awk. Trying... (4 Replies)
Discussion started by: Ikon
4 Replies

9. Shell Programming and Scripting

awk help..string display

Dear All I had input file as mention below. <RXMFP:MO=RXOTX-46-5; RADIO X-CEIVER ADMINISTRATION MANAGED OBJECT FAULT INFORMATION MO BTSSWVER RXOTX-46-5 ERA-G04-R11-V01 RU RUREVISION RUSERIALNO 0 RUPOSITION ... (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies

10. Shell Programming and Scripting

using awk make an field as 5 digit and display

using awk convert 3 rd fileld of file as 5 digit and then display changed file. like 1 2 23445 3452 3343 3 5 6 6 ================ o/p:- 1 2 23445 3452 03343 3 5 00006 6 (1 Reply)
Discussion started by: RahulJoshi
1 Replies
Login or Register to Ask a Question