Issues with sed on SunOS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issues with sed on SunOS
# 1  
Old 10-05-2012
Issues with sed on SunOS

Why does the below command doesnt work fine on SunOS 5.10

Code:
$ cat t
  |  AK|   |   | |  |  DS   |   |   |   |  tAR |   |   | |  |  FIL   |


$ sed -e 's/^ *//g' -e 's/ *$//g' -e 's/ *| */|/g' t
|AK|||||DS||||  tAR|||||FIL|

##notice before tAR

works fine on Linux OR AIX though

Code:
$ sed -e 's/^ *//g' -e 's/ *$//g' -e 's/ *| */|/g' t
|AK|||||DS||||tAR|||||FIL|

# 2  
Old 10-05-2012
How about this way:

Code:
cat file

  |  AK|   |   | |  |  DS   |   |   |   |  tAR |   |   | |  |  FIL   |


sed 's/[^\(A-Za-z\|)]//g' file

|AK|||||DS||||tAR|||||FIL|

# 3  
Old 10-05-2012
try this...
Code:
sed 's/[ \t]\+//g' file

# 4  
Old 10-05-2012
Have you tested before posting?
Code:
$ sed 's/[ \t]\+//g' t
  |  AK|   |   | |  |  DS   |   |   |   |  tAR |   |   | |  |  FIL   |

... ( on a Solaris10...)
# 5  
Old 10-05-2012
Quote:
Originally Posted by vbe
Have you tested before posting?
Code:
$ sed 's/[ \t]\+//g' t
  |  AK|   |   | |  |  DS   |   |   |   |  tAR |   |   | |  |  FIL   |

... ( on a Solaris10...)
ohh.. Sorry for this... i don't have Solaris...Smilie

i thought that it should work.. bad luck...Smilie
# 6  
Old 10-05-2012
thanks for the replies,but my concern here is why doesnt that work fine on SunOS 5.10
# 7  
Old 10-05-2012
@PAMU:
It doesnt work on HP-Ux or AIX either... You must remember before replying that linux IS NOT unix... you will find that what you can do (fancy) under linux has fewer chances to work on true UNIX like
Code:
*/5 * * * * /<path>/some-batch

in cron, you will find the same for tar, awk etc...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issues with using sed with word delimiters \< and \>

sed is not applying /d "delete line" option when I also include match word options \< and \> examples... echo cat | sed '/\<cat\>/d' will return cat for some reason echo cat | sed "/\<cat\>/d" will also still return cat. Of course I can just run this... echo cat | sed '/cat/d' and... (1 Reply)
Discussion started by: escooter87
1 Replies

2. Shell Programming and Scripting

Issues in sed command

I use SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux We have a user-defined command called "submit" which will open a vi terminal in which we need to enter the description at 24th line and save it. In order to simplify this, i decided to create another command in which the... (3 Replies)
Discussion started by: pandeesh
3 Replies

3. Shell Programming and Scripting

Issue with SUNOS running sed scripts

Hi I probably dont have GNU extended sed in my SUNOS . and its creating lot of problems ex: a simple sed command like this is not working sed '/WORD/ a\ sample text line 1 \ sample text line 1 ' filename sed: command garbled: /WORD/ a I took precaution to have a new line after... (11 Replies)
Discussion started by: vash
11 Replies

4. Shell Programming and Scripting

Sed: removes \ from text which causes issues

Hi all, Hoping someone hoping someone might be able to help. i've got the following sed command which i'm using in a bash script that i'm trying to use to insert a new line into an already existing file so i don't have to manually enter it when setting stuff up. the existing script test2/3 are... (3 Replies)
Discussion started by: springs2
3 Replies

5. Shell Programming and Scripting

sed special characters issues

I am dusting off the sed cobwebs and had a basic question: I have a file that contains: $firewall = "on"; $cache = "on"; $dataset{'mary had a little lamb'} = "on"; and want to only change the contents of what is between the single quotes: $dataset{'big bad wolf'} = "on"; I... (3 Replies)
Discussion started by: metallica1973
3 Replies

6. Shell Programming and Scripting

Filtering Issues Using sed and awk

Hi, I am currently using the sed and awk commands to filter a file that has multiple sets of data in different columns. An example of part of the file i am filtering is as follows; Sat Oct 2 07:42:45 2010 01:33:46 R1_CAR_12.34 Sun Oct 3 13:09:53 2010 00:02:34 R2_BUS_56.78 Sun... (4 Replies)
Discussion started by: crunchie
4 Replies

7. Shell Programming and Scripting

sed issues

Hi guys, not that used to using sed beyond the simple substitution. I am trying to check for a program (program1) and if it exists replace the standard output "program1" with a "program1(part1 part2) output if said program exists. SW="program1 program2" PROGRAM_TEST='echo "$SW" | grep... (3 Replies)
Discussion started by: mikepegg
3 Replies

8. Shell Programming and Scripting

sed issues with strange char

Hi all, I try to create a shell script to had the xiti tag at the end of servals web pages just before the <body/> tag. here is my script : #!/bin/bash ################################################################## rm -R /home/hibern/TEMP/hibern cp -R... (5 Replies)
Discussion started by: hibern
5 Replies

9. Shell Programming and Scripting

sed on SunOS 5.10

Hello all, I am having some problems using sed on a sunOS 5.10, I am using bash. For some reason the regexp I am trying to build is not working, even though it should. I am trying to parse some syslog messages and I need to match the first IP address , then replace it with something else.... (11 Replies)
Discussion started by: sylaan
11 Replies

10. UNIX for Advanced & Expert Users

Migration of binary file from Sunos 5.8 to Sunos 5.9

I have compiled binary file using "cc" on SunOS 5.8 and the same binary file i have copied to SunOS 5.9 and it is giving me core dump error.I want to know whether migration of compiled code from lower version to higer version created this problem. how can i solve this problem.I am pasting the core... (1 Reply)
Discussion started by: Arvind Maurya
1 Replies
Login or Register to Ask a Question