Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

output file redirect from sed is empty when run from Solaris7/AIX4.3

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am having some problem with my script, hopefully someone can help. When I ran the script in bourne shell in Redhat then everything works fine. But when I ran in bourne shell in Solaris7 or AIX4.3 or HPUX 11.x, the output from my second and third sed command are empty file.

---sed part of script---
case "$OPTION_IN" in
.
.
.
f|F) sed -e 's/^/'"$Z"'/' file1 | tr -s "\n" " " > out1;
sed -e 's/^/'"$Z1"'/' out1 > out2;
sed -e 's/$/'"$Z2"'/' out2 > out3;
;;
q|Q) break ;;
*) echo "Invalid choice." ;;
esac
do
exit
----------------------
where Z1="some_text_string"
Z2=filename

Any help is appreciate.
Thank you
 
P_N:

On your non-linux system, check the contents of file out1, and determine if the translate command is working. The translate, tr, command does have portability problems.

For example, consider the contents of x.file:
Line 1 # file with lines 2 and 3 with carriage return

Line 4

Under Red Hat 7.1:

cat x.file|tr -s "\n" " "

the output is:

line 1 line 4

Under Solaris 7:

line 1
line 4



Regards,

Ed
 
Hi Ed,
Yes, in my out1 file, the translate is working (multiple lines does get converted into a single line).
I am suspecting that the 2nd and 3rd sed lines not working in non-linux OS. When I ran the command manually, it does not return any error, but the output is also empty.
So if tr is working, what could be wrong?
Thanks,
P_N
 
P_N:

Sorry, but I don't know. If you can provide a sample of file1, I'll be glad to look at it.

Regards,

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top