using Sed in Solaris bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using Sed in Solaris bash
# 1  
Old 07-23-2009
Data 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
#------------------------------------------------------------------------------------------------------------
# Shell : KSH


CODE :
echo TWO
ls -lt /$HOME/*.html
sed "s/Count/$COUNT/g" ${CONFIG_PATH}/news.html > ${CONFIG_PATH}/temp_query.html | mv ${CONFIG_PATH}/temp_query.html ${CONFIG_PATH}/news.html
echo THREE
ls -lt /app.1.0.2/*.html
rc2=$?

executed in bash shell using command:

sh -x new.ksh parameter1

Execution:
+ echo TWO
TWO
+ ls -lt /app.1.0.2/news.html
-rw-r--r-- 1 abc abc 1799 Jul 23 10:25 /app.1.0.2/news.html
+ mv /app.1.0.2/temp_query.html /app.1.0.2/news.html
+ sed s/Count/ 0/g /app.1.0.2/news.html
+ echo THREE
THREE
+ ls -lt /app.1.0.2/news.html
-rw-r--r-- 1 abc abc 0 Jul 23 10:25 /app.1.0.2/news.html
rc2=0


Looking at the execution all the variables are substituted ... I am not able to understand what is happening Smilie .. need help

Last edited by acharania2011; 07-23-2009 at 07:13 AM..
# 2  
Old 07-23-2009
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
# 3  
Old 07-23-2009
Quote:
Originally Posted by acharania2011
I am trying to execute a script with sed that works well in ksh(Linux) however in bash(solaris 8)
I suppose you mean the opposite: bash(Linux) vs ksh(Solaris 8).
The following line from your script is bogus.
You do not at the same time redirect a command to a file and pipe its output elsewhere. Moreover, mv isn't a command that expect a file from its standard input.
Code:
sed "s/Count/$COUNT/g" ${CONFIG_PATH}/news.html > ${CONFIG_PATH}/temp_query.html | mv ${CONFIG_PATH}/temp_query.html ${CONFIG_PATH}/news.html

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Solaris bash

Hi- I have Solaris 11.3 OS. When I log in and open a terminal I get the following: user@localhost root@localhost but after I create a user manually..I just get bash$ How do I add this user profile to work with my host name ? Thanks (1 Reply)
Discussion started by: dylan69
1 Replies

2. Debian

Using sed with bash variables

Hi Guys I have another problem I'm trying to solve and hope that some one can help me here. This is the scenario: I have a file and I want to add a line on the 3rd line of the file using a bash script. but instead its adding the the bash variable $WEBSITE. Below is the bash script I'm... (6 Replies)
Discussion started by: linuxjunkie
6 Replies

3. Shell Programming and Scripting

Wget in bash using sed and awk

In the bash below when the program is opened the download function runs and downloads the getCSV file and on the screen "Downloading getCSV.csv:%" displays and when it completes the menu function is called. However, as of now the bash opens and closes after a few seconds and I'm not sure... (4 Replies)
Discussion started by: cmccabe
4 Replies

4. Shell Programming and Scripting

Bash and sed compatibility

Hi i am having a stange problem. Basically for my sed script used within bash i can unly use a single Quote with sed '. (if i use " then i get command garbled error with sed ) The problem with this is BASH does not interprit variables within single quote ' so we cannot use any of the BASH... (7 Replies)
Discussion started by: vash
7 Replies

5. Shell Programming and Scripting

sed not working in a bash script

Hi friends, I have two files - input and commands I want to read the input and replace a value in it with the contents in commands. My script is like this. Instead of printing the value in the commands file, it is simply printing $cmd in the output file. Any pointers are highly... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

6. Homework & Coursework Questions

Bash Scripting - sed (substitue)

1. The problem statement, all variables and given/known data: I have been asked to create a bash script to delete comments from another file but in the file they have an echo command with this inside of it /* this is an echo */\ so obviously they want to keep this one in the file. I have found... (5 Replies)
Discussion started by: syco__
5 Replies

7. Shell Programming and Scripting

Delete lines with SED in Bash?

Hello everyone I'm doing a program in bash and wanted to know how can I do to delete document lines the words not ending in S with SED, ie, show only those ending with the letter S. I probe with: sed -e /$.*/d "$file" | more to delete all lines NOT ending in S but not work!... (3 Replies)
Discussion started by: adiegorpc
3 Replies

8. Shell Programming and Scripting

Bash sed problem

Hi, I need to escape slashes in my text, so I use this line: search_string=`echo $var | sed 's@/@\\\/@g'`I expect that to replace a slash with a backslash followed by a slash. That works nicely, but it has a problematic side-effect. If there are two spaces in the var it replaces them with... (3 Replies)
Discussion started by: RickS
3 Replies

9. UNIX for Dummies Questions & Answers

$ in sed under tcsh vs bash

In bash, I can match the ' character in a substition involving the line ending symbol $, easily. In tcsh I ran into a problem. Code: sed "s/$/'/g" filename sed "s/$/'/g" < filename sed -e "s/$/'/g" filename Unmatched '. Where can I find out why this is the case? (2 Replies)
Discussion started by: uiop44
2 Replies

10. Shell Programming and Scripting

BASH -- sed -- variable

Hi, I'm new at bash scripting -- can anyone here help me about the sed command? I need to be able to edit and or delete a text from an outside file ie file.txt -- I'm passing a variable and not a string I was thinking of something like echo -n "What do you want to edit?: " read edit sed... (1 Reply)
Discussion started by: Imajean
1 Replies
Login or Register to Ask a Question