Special Character SED/AWK removal


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Special Character SED/AWK removal
# 1  
Old 02-26-2009
Special Character SED/AWK removal

I have a script that produces an output containing '/.ssh'.

I am trying to find a way of parsing only this data from a single line, without removing any other special characters contained within the output as a result of the parse.

Any help would be appreciated
# 2  
Old 02-26-2009
It is unclear what you mean by 'parsing only this data from a single line'. If it is a single instance within a file and you simply want to remove it the following will work.
Code:
sed 's/\/\.ssh//' file

# 3  
Old 02-26-2009
I don't understand what special characters you expect to find in the string "/.ssh", or why you need to parse it from a file instead of just giving your program the string "/.ssh" in the first place.
# 4  
Old 02-26-2009
Apologies, '/.ssh'. is displayed at the start of the output i've parsed.

The output is generated by an Expect script SSHing to an external server and Grepping a file for data

It is then called via a PHP web interface, and when the data is called, the first line has '/.ssh'. at the start.

I need a way of parsing '/.ssh'. from the initial line of the output, while not affecting the rest of the output

I hope this is clearer,

@fpmurphy: sed 's/\/\.ssh//' seems to be on the right tracks, however leaves me with ''.

Cheers,
# 5  
Old 02-26-2009
Quote:
Originally Posted by Raggedranger333
@fpmurphy: sed 's/\/\.ssh//' seems to be on the right tracks, however leaves me with ''.
Ah, you just need to remove the very first line?

Code:
( read ; cat )

read will eat the first line, and cat will just copy the rest to stdout.
# 6  
Old 02-26-2009
Ideally I'd like to keep the first line of the output as sometimes the data from the Grep will only contain 1 line

Any further help would be appreciated.
# 7  
Old 02-26-2009
So you want to check what the first line is, without actually altering any of the data?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed add special character

Hi all I got test.test.test and need test.test\.test * I need the backslash before the last dot in the line I tried echo test.test.test | sed 's/\./\\./g' but it gives me test\.test\.test Thanks (7 Replies)
Discussion started by: stinkefisch
7 Replies

2. UNIX for Dummies Questions & Answers

Replacing special character with sed

Hi All, I have a text file that contains I1SP2 *=*=Y=M=D001D My requirement is to replace all occurrence of =* to =Z expected o/p is I1SP2 *=Z=Y=M=D001D I have tried with sed 's/=*/=Z/g' file sed 's!\=*!\=Z/g' file sed 's!\=*!\=Z!g' file sed 's!\=\*!\=Z!g' file but its not... (3 Replies)
Discussion started by: gotamp
3 Replies

3. Shell Programming and Scripting

awk trailing character removal

Hi, The command - id | awk '{print $1}' - returns the following: uid=9028(luke) What do I need to further that awk so that I only have "luke", I want to set this as a variable. Thanks in advance, Lukas. P.S: I've come up with: USER1=`id | awk F'(' '{print $2}' | awk -F')' '{print... (4 Replies)
Discussion started by: luke222010
4 Replies

4. Shell Programming and Scripting

sed help with character removal

Hello I've got a string of text with a number in pence, e.g. 0.52p, I need to remove the 'p' so that it just reads 0.52 without of course removing all the other 'p' characters. Many thanks (1 Reply)
Discussion started by: mrpugster
1 Replies

5. OS X (Apple)

vi and special character removal

To the group, when I copy text from a web page that has the below java code , and then do the set list command in the vi editor, I see the $ symbol at the end of each line. I have searched the internet looking for a way to remove this from the file since it will not compile without errors..Please... (6 Replies)
Discussion started by: smartino
6 Replies

6. Shell Programming and Scripting

any savant ? using AWK/SED to remove newline character between two strings : conditional removal

I'd like to remove (do a pattern or precise replacement - this I can handle in SED using Regex ) ---AFTER THE 1ST Occurrence ( i.e. on the 2nd occurrence - from the 2nd to fourth occurance ) of a specific string : type 1 -- After the 1st occurrence of 1 string1 till the 1st occurrence of... (4 Replies)
Discussion started by: sieger007
4 Replies

7. Shell Programming and Scripting

how to replace the special character with another using SED

I have the replace the pattern in the file , ); to ); Could someone please help me to get this command. (2 Replies)
Discussion started by: mohan.bit
2 Replies

8. Shell Programming and Scripting

Decode %s Special Character in Sed

Greetings, I am doing something that I don't know if it is possible... I have a file with a line looks like this: <%s \n%s / %s \n%s \n> and I am trying to replace this line with <%s \n%s \n%s / %s \n%s \n> in Shell script with sed command... StringToReplace='%s \n%s / %s \n%s \n'... (2 Replies)
Discussion started by: wasabihowdi
2 Replies

9. Shell Programming and Scripting

Sed-Special character replacement

Hi I want to replace ./testsed.ksh with testsed.ksh ./ is to be removed scriptnm=`sed -e 's/\.///' $0 does not work Please help (3 Replies)
Discussion started by: usshell
3 Replies

10. Shell Programming and Scripting

sed and special character in data

I have a script that is reading an existing report, pulling out the customer code, then tacking on the customer name from another file and replacing the existing customer code with the new field. This was written for me by someone else. I'm not real familiar with sed. The data is getting into... (3 Replies)
Discussion started by: MizzGail
3 Replies
Login or Register to Ask a Question