using awk with space


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using awk with space
# 8  
Old 04-12-2005
ksh ......
# 9  
Old 04-12-2005
strange well im outta ideas ... Smilie
# 10  
Old 04-12-2005
Computer

I don't see any issues with your second code

This is what i got :

/home/test >echo "gives Me Output Like This" | awk '{print $1 " " $2 " " $3}'
gives Me Output
# 11  
Old 04-12-2005
Quote:
Originally Posted by strike
strange well im outta ideas ... Smilie
it's got nothing to do with 'awk', but rather with the 'for' loop itself. The loop reads one string at the time and echo-s it out.

you can try something like this instead:
Code:
#!/bin/sh

awk '/hello there/ {print $1,$2,$3}' $FILE | while IFS= read SOMELINE
do
   echo $SOMELINE
done

# 12  
Old 04-12-2005
ohh i think it must be a problem with the file im trying to read,
i just tried

/home/test >echo "gives Me Output Like This" | awk '{print $1 " " $2 " " $3}'

and it works fine. thanks Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Create the space only in the Third column by awk

Hi All , I am having an input file like this Input file r s e y Pin Numbers s n eppppppppppppppppppc ... (3 Replies)
Discussion started by: kshitij
3 Replies

2. Shell Programming and Scripting

awk to escape space in name

I am searching a file and not able to escape a space if $i has a space in the name. I tried escaping it with a \ and also trying to add it to allow for spaces in the search. Neither are correct as the first awk only outputs path and the second awk doesn't run. Thank you :). first awk awk... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

Need to use delimiter as : and space in awk

Hi , Please suggest me how do I use : (colon and one space) as a delimiter in awk Best regards, Vishal (2 Replies)
Discussion started by: Vishal_dba
2 Replies

4. UNIX for Advanced & Expert Users

Need to remove leading space from awk statement space from calculation

I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation? Here is my query: cat myfile.log | grep | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}' 02:00:00... (1 Reply)
Discussion started by: bizomb
1 Replies

5. Shell Programming and Scripting

awk print used space

Hi Team, Can you please tell me how to get a used space in KB LINUX and free space in KB separate commands. For example: $df -k /rer (apdfp01.xxx.com:/var/adm/rash/MT) : 2066900 total allocated Kb 4579 free allocated Kb 16121 used allocated Kb 89 % allocation used /dev/deviceFS1... (5 Replies)
Discussion started by: indira_s
5 Replies

6. Shell Programming and Scripting

AWK - Ignoring White Space with FS

I have an AWK script that uses multiple delimiters in the FS variable. FS="+" My awk script takes a file name such as this: 12345_smith_bubba_12345_20120215_4_0.pdf and parses it out based on the under score. Each parsed field then has some code for data validation etc. This script has... (12 Replies)
Discussion started by: reno4me
12 Replies

7. Shell Programming and Scripting

Space with awk

Hi, Need some help with awk and blank fieds.. # last -n 2 gml4410 pts/0 host3 Fri Nov 18 07:46 - 07:53 (00:06) nmc5060 host2 Thu Nov 17 15:29 - 15:30 (00:00) I need to extract field1(userid) , field5(month) and field 6(day). Notice the second line has blank space... (2 Replies)
Discussion started by: vignes10
2 Replies

8. UNIX for Dummies Questions & Answers

awk for variable with a space

Hi experts, why does $ echo "one two three" | awk '{$3="my tree"; print $0}' one two my tree work, but $ var="my tree" $ echo "one two three" | awk '{$3="'$var'"; print $0}' awk: {$3="my awk: ^ unterminated string does not work? How can the variable tha contains a space be... (2 Replies)
Discussion started by: GermanicGalore
2 Replies

9. Shell Programming and Scripting

Replacing / with a space using awk

I have a string and want to replace the / with a space. For example having "SP/FS/RP" I want to get "SP FS RP" However I am having problems using gsub set phases = `echo $Aphases | awk '{gsub(///," ")}; {print}'` (5 Replies)
Discussion started by: kristinu
5 Replies

10. Shell Programming and Scripting

Search with awk, but having space within

If in my search string with awk, if I have spaces, I am getting an awk error. e.g. awk /A B/ filename How can I search the pattern which has space within? (1 Reply)
Discussion started by: videsh77
1 Replies
Login or Register to Ask a Question