awk search for space character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk search for space character
# 1  
Old 03-30-2011
awk search for space character

How do I use awk to search for a string that contains a space bar?

I have tried this
Code:
awk '/send email/ {print $0}' input

Code:
awk '/send\ email/ {print $0}' input

# 2  
Old 03-30-2011
Code:
awk '/send email/ {print $0}' input

should work.
Use nawk if you are on solaris/SunOS

---------- Post updated at 04:21 PM ---------- Previous update was at 04:19 PM ----------

Code:
# cat tst
fjdskllkdsgpgrfp
jdsqlfjkdls send mail gfdsjgkl
send mail klvgmfdskglmds
sqkfjdskqjfsq
lfldsmkq send mail
fdksmlqfmldsmq
fdlmqkfm fkmldq
fdmlsq kfdlmsk fkdsqm
send mail
# awk '/send mail/' tst
jdsqlfjkdls send mail gfdsjgkl
send mail klvgmfdskglmds
lfldsmkq send mail
send mail
#

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Search for a pattern and replace a space at specific position with a Character in File

In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123. So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Discussion started by: Jagmeet Singh
3 Replies

2. Shell Programming and Scripting

awk search for max and min while ignoring special character

I am trying to get a simple min/max script to work with the below input. Note the special character (">") within it. Script awk 'BEGIN{max=0}{if(($1)>max) max=($1)}END {print max}' awk 'BEGIN{min=0}{if(($2)<min) min=($2)}END {print min}' Input -122.2840 42.0009 -119.9950 ... (7 Replies)
Discussion started by: ncwxpanther
7 Replies

3. Shell Programming and Scripting

Read character by character in line in which space is also included

Hi friend, I have one file , and i want to read that file character by character. I need this script in ksh. while using read option with -n1 am getting error. while read -n1 c read has bad option And if i am using below script, then if in a line has space like this ( Pallvi mahajan)... (10 Replies)
Discussion started by: pallvi_mahajan
10 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

Regex space character

Hi, I have following regex condition, however it does not work with different logs having same visible string.I believe it is because of some difference with space character, is it possible to make it work everywhere. Can someone suggest a better string? /BIND dn=" uid=/ Thanks. (8 Replies)
Discussion started by: susankoperna1
8 Replies

6. Shell Programming and Scripting

Remove space before a character

Hi guys, I am new to shell scripting and I have a small problem...If someone can solve this..that would be great I am trying to form a XML by reading a flat file using shell scripting This is my shell script LINE_FILE1=`cat FLEX_FILE1.TXT | head -1 | tail -1` echo... (1 Reply)
Discussion started by: gowrishankar05
1 Replies

7. UNIX for Dummies Questions & Answers

sed with variable containing space character

Hi all, I have the following script S1a="13 9 -0.0012041" S1b="13 8 -1.00000 " sed 's/${S1b}/${S1a}/g' funE00.i > tmp1 but the strings are not replaced. Maybe the problem is in the spaces cointaned in the variables? Thanks for your help, Sarah (2 Replies)
Discussion started by: f_o_555
2 Replies

8. AIX

How can i replace a character with blank space?

i want a command for my script!!! say file consists of character 123 125 127. i need a query to replace the number 2 with 0 so the output should be 103 105 107. i use unix-aix (8 Replies)
Discussion started by: rollthecoin
8 Replies

9. UNIX for Dummies Questions & Answers

separate information with a space character

Hi, I would like to display a sorted list (based on the login name) of the login name, the home directory and the default shell of each user defined on the system ; I just do cut -d: -f1,6,7 /etc/passwd | sort And then I would like to separate each information with a space... (2 Replies)
Discussion started by: remid1985
2 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