shell program with sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell program with sed
# 1  
Old 04-08-2010
shell program with sed

I want to substitute a charactor "PAN" with "TAN" in a shell, I used sed command in shell, it wo'nt work but the same is run from command prompt it was successful. the command is

sed ' s/PAN/TAN/g ' <i/p> > <o/p>
sed ' s/^M/^M/g ' <i/p> > <o/p> (1st ^M is Ctrl+V+M, 2nd should be line feed/next line)

the same problem is with delete option in sed

Please suggest
Image


---------- Post updated at 08:44 AM ---------- Previous update was at 08:27 AM ----------

Quote:
Originally Posted by anil_kut
I want to substitute a charactor "PAN" with "TAN" in a shell, I used sed command in shell, it wo'nt work but the same is run from command prompt it was successful. the command is

sed ' s/PAN/TAN/g ' <i/p> > <o/p>
sed ' s/^M/^M/g ' <i/p> > <o/p> (1st ^M is Ctrl+V+M, 2nd should be line feed/next line)

the same problem is with delete option in sed

Please suggest

Image
actually file consist of single line with multiple ^M character, i am trying to convert all ^M character into line feed i.e new line (so that single line file become multiple line sequential file), the same works from comman line but not from shell program.

thanks
# 2  
Old 04-08-2010
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

Proceed here:

https://www.unix.com/shell-programmin...33883-sed.html

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED: language translation of a program

Hi people! I'm a bit noob at sed so I ask you for some help :( I'm trying to automatically translate some files of a program, which has some lines of this style: $string = 'A text line'; For example in this line: $string = 'The date entered: <strong>$a</strong> does not correspond... (2 Replies)
Discussion started by: pdmiguel
2 Replies

2. Shell Programming and Scripting

modify and use awk sed program

The following awk script creates a file b.dat. awk '{print substr($0,1,27),substr($2,index($2,"_")+1)," ",substr($0,49)}' a.dat > b.dat I need this script to be modified to also sum $3 values by distinct $1 and $2 fields. Current file W2_2009275 2 8 W2_2009275 2 7 W1_2009275 1... (3 Replies)
Discussion started by: mnnarendra
3 Replies

3. UNIX for Advanced & Expert Users

unix awk/sed program

i need a sample unix awk/sed program to replace param3 in a file. i have sample file a.dat with the following format/length (week 8, sku 20, store 20 and qty 8). all store id's which end with _2 needs to be replaced with div id 2. all store id's which end with _1 needs to be replaced with div id... (4 Replies)
Discussion started by: mnnarendra
4 Replies

4. Shell Programming and Scripting

shell program

Iam having file 1 as wc -l file1 is 8 QWEERTYUU|7927836357398398398913 yuyuyu uyiuyuyuyuy yuiyuiyuyuyy FDHGFSHAJK|1476887897877777777771 iopwiiwpoi e . . . . I Need to read the abouve line in file1 so iam using the command as tail -n 8... (8 Replies)
Discussion started by: nivas
8 Replies

5. Shell Programming and Scripting

How to use shell script's to get EPG Program with SED

This is my test script version: #!/bin/sh wget -q -O /tmp/axn 'http://www.axn.pt/programacion/' sed -e '/^$/ d' /tmp/axn > /tmp/temp #Clean black space sed -e 's/<*>//g' /tmp/temp > /tmp/temp1 #Remove HTML rm -f /tmp/temp # Step by step script then clean one by one sed... (3 Replies)
Discussion started by: single
3 Replies

6. Shell Programming and Scripting

help with shell program

I want to print the value of variables a1, a2, a3 in for loop in the following program: a1=this a2=is a3=printed for((i=1;i<4;i++)) do var=a$i #w=`echo $var` e=${var} echo $e done But actually I get a1,a2,a3 as the output not the "this is printed" So the main question is if I... (3 Replies)
Discussion started by: adgarg
3 Replies

7. Shell Programming and Scripting

shell program

How to write a shell script which takes 3 strings as positional parameters,first and second are file names and third is a directory.if the two files exist in `pwd` and they contain a specific pattern and their size is greater than 32 bytes,moves these files into directory? (1 Reply)
Discussion started by: rameshparsa
1 Replies

8. Shell Programming and Scripting

How to use sed within shell program?

Hi, I tried this with my shell program and it didn't work: /usr/ucb/sed '/$employeeID/d' /usr1/log/logfile How to let sed see my variable employeeID within my shell program? Thanks! (1 Reply)
Discussion started by: whatisthis
1 Replies

9. Programming

Shell Program

I am programming the following simple shell program. It works for the most part, things like 'ls' and 'ps' work just fine. However when I add options, (example, ls -l) it does not execute the command. Also, I've been trying to add an "exit" command, so that I don't have to use the iterrupt; but... (3 Replies)
Discussion started by: TexasGuy
3 Replies

10. Shell Programming and Scripting

Help me with this Shell Program

Now, am in a very tight situation here. I really dont expect anyone to understand but please, try your best. am trying to right a program that goes back to the previous entry to correct a mistake. heres what am trying to do. i write a program like this Name : James Holgston... (1 Reply)
Discussion started by: TRUEST
1 Replies
Login or Register to Ask a Question