calling sed problem!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting calling sed problem!!
# 1  
Old 05-02-2007
calling sed problem!!

please help:
I want to append the word "world" after every line that ends with hello:
$cat file
hello
hello$ sed '/hello/ a world' file
sed: Function /hello/ a world cannot be parsed.

What's wrong with the above command??

If a hit a new line it works:
$ sed '/hello/ a\
> world' file
hello
world
hello
world

How to make the first call work (without new line)???

Andy
# 2  
Old 05-02-2007
Andy,
To append "string2" to the end of every line that ends with "string1":
Code:
sed 's/string1$/&string2/' input_file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't remove spaces with sed when calling it from sh -c

The following command works echo "some text with spaces" | sh -c 'sed -e 's/t//g''But this doesn't and should echo "some text with spaces" | sh -c 'sed -e 's/ //g''Any ideas? (3 Replies)
Discussion started by: Tribe
3 Replies

2. Shell Programming and Scripting

Csh variable calling problem

First post on here. So I use csh shells for my research (physics... not a CS person). I am trying to rerun the same scripts, but there are ~10 files that have similar variables that I have to change for each different configuration, so I would like one central file for the variables I change that... (3 Replies)
Discussion started by: sabrepride
3 Replies

3. UNIX and Linux Applications

Controller problem: Error calling DSRunJob

Hi I got this error : Controller problem: Error calling DSRunJob(JOBNAME.), code=-2 can some tell me, what it means? (0 Replies)
Discussion started by: Avi
0 Replies

4. Programming

gfortran compiling problem,calling too many arguments

Hello, My problem is with compiling a program modelling shallow water. In it there is a subroutine called stat with 9 parameters. In the main program it is called with 9 parameters also I'm running Ubuntu 11.04 with gfortran version 4.5. Thanks. ---------- Post updated at 11:57 PM... (0 Replies)
Discussion started by: b_franz
0 Replies

5. Shell Programming and Scripting

PERL script -- calling 'sed' by passing 'variable value'.

Hi Friends, I'm calling 'sed' command inside one perl script, which is to list directory names which are having some date value as their names (in the form YYYYMMDD) with in the range (start and end date). #!/usr/bin/perl -w use strict; use warnings; my $DATA = "/export/home/ganapa"; my... (5 Replies)
Discussion started by: ganapati
5 Replies

6. Shell Programming and Scripting

Calling Function Problem

Hi, I had a scripts which calls two function. One function will call another function, script is working fine but the second function is not calling the first function. Below is the script #!/usr/bin/ksh fun1() { echo $DATETIME >> Test1.ksh return 0 } fun2() { typeset DATETIME=`date... (5 Replies)
Discussion started by: somu_june
5 Replies

7. Shell Programming and Scripting

calling problem in perl script

Hi , Here is my piece of code-- main(); sub main { $result = GetOptions ("LogDir=s" => \$LogDir, "Summary" => \$Summary, "Indiviual=s" => \$Individual , "Diagnostics=s" => \$Diagnostics, ... (1 Reply)
Discussion started by: namishtiwari
1 Replies

8. Shell Programming and Scripting

Problem with Calling sql file from shell script

I have created abc.sh file which will set the environment variables (UNIX env variables as well as ORACLE required variables like ORACLE_SID,ORACLE_HOME etc) and then calls a function file which checks for starts some logs and then it will try to execute the .sql file. The .sh, function file are as... (1 Reply)
Discussion started by: sskc
1 Replies

9. Shell Programming and Scripting

shell script calling problem

Hi all, I am calling one shell script from other ...as follow ---calling_proc---code line_no=10 proc_name='test' echo "set verify off feedback off pagesize 0 select count(*) from tp_mpolicy2 " | sqlplus -s/@CMKT | read cnt if ; then export $line_no $proc_name global_proc... (2 Replies)
Discussion started by: dhananjaysk
2 Replies

10. Shell Programming and Scripting

Problem in subroutine calling

Hi, we can call the subroutines using two ways .... 1) calling subroutine name preceeded by & symbol. 2)Another one is without &symbol.... what is the diff b/w these two.... ############################ #usr/bin/perl fun; sub fun { print "hi this is from perl\n"; }... (1 Reply)
Discussion started by: sarwan
1 Replies
Login or Register to Ask a Question