sed Solaris Problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed Solaris Problem
# 1  
Old 07-10-2010
sed Solaris Problem

Hello. has anybody an idea why my script doesnt work on solaris but on ubuntu? I know. I ask the same question again. But i really dont know why my script is not working.


Code:
#!/usr/xpg4/bin/sh
for file in $(find /home9/user/..../.../Test/ -type f)

do
head -n 1 $file | egrep '^#!' 
if [ $? -eq 0 ] 
    then

/usr/xpg4/bin/sed '2i\header' "$file" > "$file.new" && mv "$file.new" "$file" 

else

/usr/xpg4/bin/sed '1i\header' "$file" > "$file.new" && mv "$file.new" "$file"
fi


done

I get message : sed garbled and everything he does is to create new empty files....

Where is the Problem here.Is the path wrong or something...

Thanks a lot
# 2  
Old 07-10-2010
Try:
Code:
#!/usr/xpg4/bin/sh
for file in $(find /home9/user/..../.../Test/ -type f)

do
head -n 1 $file | egrep '^#!' 
if [ $? -eq 0 ] 
    then

/usr/xpg4/bin/sed '2i\
header' "$file" > "$file.new" && mv "$file.new" "$file" 

else

/usr/xpg4/bin/sed '1i\
header' "$file" > "$file.new" && mv "$file.new" "$file"
fi


done

# 3  
Old 07-10-2010
unbelievable

it works. Many thanks to you and greeting to amsterdam
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed Or Grep Problem OR Terminal Problem?

I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore. Here is what 's happening: * I wanted to remove lines containing digits so I used this... (25 Replies)
Discussion started by: Nexeu
25 Replies

2. Shell Programming and Scripting

[SOLVED] sed -i not available in solaris 5.10

Hi All, i'm writing a script where i have to grep for a pattern and the 3 lines after the pattern and comment them out. Note that i have to do this for multiple files, i am able to grep the pattern and the next 3 lines but since solaris does not recognize the -i option, i was wondering if... (11 Replies)
Discussion started by: Irishboy24
11 Replies

3. Shell Programming and Scripting

solaris sed equivalent

Hi Experts, I am using this command to edit the file contents and also add the header to the existing file. I prepared this command on my VM (Linux) and it worked as I wanted it to work. But on solaris its not working :(. Please help as it is quite urgent. sample File: a b Output... (5 Replies)
Discussion started by: sugarcane
5 Replies

4. Shell Programming and Scripting

sed problem

I am trying to use sed to make some changes to some HTML-like code. The code looks like this: <aaa bbb="xxxx" params="@abc@ @defghi@ @j@"></aaa> <aaa params="@abc@ @defghi@">value</aaa><aaa params="@klm@ @nopq@ @rstu@"></aaa> <aaa params="@v@ @wxy@ @z@"></aaa>There is an aaa tag which can... (4 Replies)
Discussion started by: RickS
4 Replies

5. Shell Programming and Scripting

SED Problem

Hi all, I want to replace the first two occurances of "Gautam" with "Gomzy" using the sed command. if i do this: sed 's/gautam/gomzy/g' <filename> Then it replaces all the occurances of gautam with gomzy. But i only want to replace the first two occurances. i tried out with this: sed... (2 Replies)
Discussion started by: gautamshaw
2 Replies

6. Shell Programming and Scripting

Sed problem

Hi again! Sed is very difficult to understand for me... :( I have a file like this And I'm looking for this result I found sed '$!N;s/\n/ /' => Put Line1 and Line2 together, Line3 and Line4... I tried |sed '$!N;s/\n*\n/ /' but it didn't work... Thanks for your help PS:And... (6 Replies)
Discussion started by: Castelior
6 Replies

7. Shell Programming and Scripting

using Sed in Solaris bash

I am trying to execute a script with sed that works well in ksh(Linux) however in bash(solaris 8) though it does not give any errors the output file becomes 0 byte. header of the script: ksh:2$ head news.ksh #!/bin/ksh... (2 Replies)
Discussion started by: acharania2011
2 Replies

8. Shell Programming and Scripting

Sed problem

HI, I have a file test which content are as APP_NAME="%APPNAME%" Now, i m using sed command to replace the %APPNAME% with variable APPNAME. Here variable value is as export APPNAME="AB" sed -i "" -e "s:%APPNAME%:$APPNAME:" ./test test file become as APP_NAME="AB" Which is... (4 Replies)
Discussion started by: Saurabh78
4 Replies

9. UNIX for Advanced & Expert Users

Sed problem

Hi, I tried the following sed -n '/one/p' file1 I need to understand, is it possible to search pattern irrespective of case. Thanks, Shahnaz. (4 Replies)
Discussion started by: shahnazurs
4 Replies

10. Solaris

Sed problems on Solaris 10

Hi, The config file: # Port(s) for accepting client connections RTSPPort=554 bash-3.00# awk -F"=" -v gr="888" '/RTSPPort/{$2=gr;}1' OFS="=" server.ini awk: syntax error near line 1 awk: bailing out near line 1 Can you help me on why this doesn't work. The next one neighter. Dosn't... (0 Replies)
Discussion started by: potro
0 Replies
Login or Register to Ask a Question