~R in between string, how to handle in AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ~R in between string, how to handle in AWK
# 1  
Old 05-24-2011
~R in between string, how to handle in AWK

Hi,
Can any one help how to handle the below situation.

Am using Awk script to handle variable

When I open the file in VI mode, I see the string as Orange~Rs , but when I cat the file its showing as plain Oranges.

When I copied the file over to Windows, am seeing the special character as Orange's.

Am trying to assign it to a variable , and its giving me hard time and using it downstream in AWK, I tried both below formarts, using Octal replacement for apostraphe.

hdr == "Oranges"
hdr == "Orange\047s"

Can anyone help me with this.

Thanks
Sunil
# 2  
Old 05-24-2011
What about filtering?

I think you are trying to get rid of these character(s)?
You could
Code:
tr -d "[:cntrl:]"

to get rid of control characters.
# 3  
Old 05-24-2011
Joey,
Thanks for replying.

Am not trying to get rid of the ~R character, but i am trying to assign it to a variable, Any of the below ways are not working.

hdr == "Oranges"
hdr == "Orange\047s"
hdr == "Orange~Rs"


Is there is way that i can assign it to a variable, without deleting it.

Thanks
Joey
# 4  
Old 05-24-2011
You could try:
Code:
hdr=`echo -e "Orange\047s"`

Though not quite elegant... it seems to work on my Linux box + bash.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to handle new line if it is EOL or present as part of string?

Hi All I am facing some issues while processing a file. The file has \n as End Of Line. However for some records '\n' is also present as part of string. Hence I am not able to identify proper records from file. File is # delimited. Example: 2 rows spread across 4 lines. line1: COL1#COL2#... (2 Replies)
Discussion started by: dashing201
2 Replies

2. Shell Programming and Scripting

Handle special characters in awk -F

Hello Folks, Need to bisect strings based on a subset. Below works good. echo /a/b/c/d | awk -F"/c/d$" '{print $1}' /a/b However, it goes awry with special characters. echo /a/b/c+/d | awk -F"/c+/d$" '{print $1}' /a/b/c+/d Desired output: /a/b Escaping the special characters... (11 Replies)
Discussion started by: vibhor_agarwali
11 Replies

3. Shell Programming and Scripting

Help -- Modify awk command to handle "," delimiter

Currently I am using this command to split a CSV file based on the distinct values in the 16th (position) column. awk -F, 'NR==1 { hdr=$0; next } $16 != prev { prev=name=$16; gsub(/_]/,"",name); $0 = hdr "\n" $0 } { print > ("/Directory/File."name".Download.csv") }'... (3 Replies)
Discussion started by: lojkyelo
3 Replies

4. Shell Programming and Scripting

Handle null values-awk

I am using below code to validate the source file,code working fine but if any column contains null value then below code throwing error actually it should not.how to customize the below code to handle null null values also. When I run the script with below source data getting “date error”, as... (2 Replies)
Discussion started by: srivalli
2 Replies

5. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

6. UNIX for Dummies Questions & Answers

Difference between handle to the thread HANDLE and thread identifier pthread_t

This question might be silly but its confusing me a bit: What is the difference between handle to the thread HANDLE and thread identifier pthread_t? ---------- Post updated at 01:52 PM ---------- Previous update was at 01:48 PM ---------- Sorry I saw details and HANDLE is in windows and... (0 Replies)
Discussion started by: rupeshkp728
0 Replies

7. Shell Programming and Scripting

AWK/SED: handle max chars in a line

Hi all, I hope you guys can help me. I prefer SED/AWK solutions if possible. For my shame it didn't work for me :o ISSUE: :wall: 1\3 1/$4\@7\ 1234567890123456789\ 1234567890123456789,\ 1234567890123456789\ 123456789012 12345 1234567890123456789\ 1234567890123456789,\ 1234... (5 Replies)
Discussion started by: unknown7
5 Replies

8. Shell Programming and Scripting

how to handle , in data where separator also commas in awk script

TEST_HEME,"SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1",CELL when I split by FS="," then $0=TEST_HEME $1="SubNetwork=ONRM_RootMoR $2=SubNetwork=ARNC1" but I need this will be single value "SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1" (4 Replies)
Discussion started by: Hemendra
4 Replies

9. UNIX for Dummies Questions & Answers

Awk cannot handle more than 30 files

I trying to search for lines with multiple search criterias in an archive of zipped files. But awk seems to have a limit. Any idea how to fix it? I'm on a sun solaris system. Here is my search string: gzcat -r *200808* | awk -v 'substr($0,50,11)=="11095512309" ||... (3 Replies)
Discussion started by: HugoH
3 Replies

10. UNIX for Advanced & Expert Users

How to handle backslash in grep string

Hi , I am doing invert grep using -v but the string contain "/" which break the grep command and it do not skip the lines with "/" on it. Diffu.txt ======== 1159c1159 < <td align="right" valign="middle" class="paddingRight2px" id="featureListItemChannelButton7466"> --- > <td... (6 Replies)
Discussion started by: rajbal
6 Replies
Login or Register to Ask a Question