How to replace special chars like " ' " (Apostrophe)
I'm goin to drive crazy soon, if i can not do this. I have a text file (570kb) and i have to replace the apostrophe " ' " and minus "-" with space " ". i have done it for minus:
.... haha I'm only reading this forum so that I can learn more myself, but I came across a similar example in a hardcopy book called "Sed & Awk" (O'reilly). According to the book you don't need to enclose your sed argument with quotes (as you have in this example - single quotes), and I'm sure this is what was breaking your statement.
I tried a few things myself and decided it was the outside quotes breaking things, and then found out you can enclose your pattern and substitution string with double quotes (not sure if singles work too). Gave it a shot and it worked.
The reason that your example fails is because these such commands rely on 'delimeter' characters to break up their data. Eg. for a program to read a string it finds the next quote - " - and then starts grabbing anything after the quote until it hits another quote - " - and then says 'everything in-between is the string'. Of course this doesn't work if the string itself contains a quote, like in your example. To get around this problem, they invented 'escape' characters which say to the program 'hey don't worry about this quote - it's part of the string' Eg:
1. "A string" = A string
2. "A string with \"escape characters\"" = A string with "escape characters"
3. "A broken string without "escape characters"" = A broken string without
Your example falls into category 3. However, I couldn't find a way to use an escape character with the single-quote. I would have thought that this would work:
- Note the \ escape character preceding the single-quote. But this doesn't work. I don't know why, if people would program like me it would work. But they don't. Which is why bad software exists. And microsoft.
Last edited by dan-e; 10-26-2008 at 10:46 PM..
Reason: Fixed ugliness
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi Guys,
I have a variable such that:
set x = (Session,Date,Type,Receive Coil Name,Manufacturer,Manufacturer's Model Name)
foreach i ($x)
echo $i
end
I would like to read each variable one by one like:
Session
Date
Type
Receive Coil Name
Manufacturer
Manufacturer's Model Name
Is... (1 Reply)
Hi all,
I have this text file containing 9 columns separated by space. The 8th columns contains the numbers.
C1 C2 C3 C4 C5 C6 C7 C8 C9
er rt yt gh iu nk il 0.07 xs
yt lr ty bg iu zk nh 0,0005 lt
...etc.
I want to replace the comma with full stop only in 8th coloumn.
the output... (8 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi,
I require to delete all characters after a dot "." from a string. For e.g.
input_var="/home/dips/file_1_20100726.txt.gz /home/dips/file_2_20100726.txt.gz /home/dips/file_3_20100726.txt.gz"
output_var="/home/dips/file_1_20100726 /home/dips/file_2_20100726... (3 Replies)
both ksh/bash support this 2 special variables, Is there any document for reference?
1) "-" is $OLDPWD
2) "$_" is last argument of previous command. (4 Replies)
HI Friends,
I am trying to elliminate the " " characters from the word:
"hello" using awk. I need the output to be just = hello (without " " chars). Is there any way to do this ?
Thanks! (3 Replies)