Problem editing with ed...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem editing with ed...
# 1  
Old 10-30-2012
Problem editing with ed...

I have troubles passing variables to ed.
i'm trying to do something like this:

Code:
#!/bin/bash

  User=`cat /etc/pmx.conf |grep User | cut -d "=" -f2`
  new=$1

ed -s /etc/pmx.conf <<< $'/User/s/$User/$new/g\nw'

:S
# 2  
Old 10-30-2012
Try replacing
Code:
$'/User/s/$User/$new/g\nw'

with
Code:
$"/User/s/$User/$new/g\nw"

.

Last edited by elixir_sinari; 10-30-2012 at 11:44 AM..
This User Gave Thanks to elixir_sinari For This Post:
# 3  
Old 10-30-2012
that's exactly the problem....

i already try it, but ed doesn't recognize the command, even if use string instead of variables....
example:

Code:
$"/User/s/actualname/newname/g\nw"

ed only recognize this same command wit single quotation...
# 4  
Old 10-30-2012
sorry, its not a related answer..
am new to this forum.. donno where to go to start questioning..

I want to get the both .txt and .dat files

How to get this

Thanks in advance
satya
# 5  
Old 10-30-2012
Quote:
Originally Posted by satyavinod
sorry, its not a related answer..
am new to this forum.. donno where to go to start questioning..

I want to get the both .txt and .dat files

How to get this

Thanks in advance
satya

maybe if you can explain yourself better, i could help you...
# 6  
Old 10-30-2012
I want to list out all the .txt files and .dat files with one unix command
How to get this two types at a time?
# 7  
Old 10-30-2012
Quote:
Originally Posted by satyavinod
I want to list out all the .txt files and .dat files with one unix command
How to get this two types at a time?
if you want to list this kind of files in terminal do

Code:
ls *.txt *.dat

if you are doing some scripting you can do some thing like

Code:
#!/bin/bash


TXT=`ls *.txt`
DAT=`ls *.dat`


echo " TXT FILES

	$TXT
	"

echo " DAT FILES

	$DAT
	"

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert vi editing to text editing

Dear Guru's I'm using Putty and want to edit a file. I know we generally use vi editor to do it. As I'm not good in using vi editor, I want to convert the vi into something like text pad. Is there any option in Putty to do the same ? Thanks for your response. Srini (6 Replies)
Discussion started by: thummi9090
6 Replies

2. Shell Programming and Scripting

Vi editing with a command

Hi Friends, we have 300+ AIX servers and wants to update /etc/secutiry/user config file to add more parameters for a user. Could you please provide shell script or command? Existing data: --------------- ramesh: admin = false minlen = 4 TO be updated: ------------------ ... (1 Reply)
Discussion started by: suresh3566
1 Replies

3. Shell Programming and Scripting

Shell quoting problem while editing a remote file using sed

value of i = solarisbox ssh $i "cat /etc/hosts | sed "s/$i\.local\.//" | sed "s/$i\./$i/" | sed "s/$i/$i.sol.com/" > /usr/users/chidori/edit_hosts"While running the above one liner its i am not able to make the changes and write it to the file /usr/users/chidori/edit_hosts . I know there is a... (2 Replies)
Discussion started by: chidori
2 Replies

4. Shell Programming and Scripting

Problem with searching and then editing a file through shell.

Hi, I have searched through this forum as there are many similar entries but could'nt get one of them to work, either that or they were just different to what I needed. Basically I have a file, recordsDatabase. In this file are a few different fields. There is a unique identifier eg 001... (5 Replies)
Discussion started by: U_C_Dispatj
5 Replies

5. Shell Programming and Scripting

problem in using sed command in editing a file

Hi all, I have a conf file, i want to update some entries in that conf file. Below is the code for that using a temporary file. sed '/workgroup=/ c\workgroup=Workgroup' /usr/local/netx.conf > /usr/local/netx.conf.tmp mv -f /usr/local/netx.conf.tmp /usr/local/netx.conf Sample contents of... (9 Replies)
Discussion started by: ranj14r
9 Replies

6. Shell Programming and Scripting

Problem in editing files in eclipse with cvs

I am using CVS repositories with eclipse. I successfully created CVS Repositories with in eclipse. But I have a big problem, I am unable to edit any of the files in our project. I think it is due to read only property of the file. I also read the given link ... (2 Replies)
Discussion started by: sufyanfzd
2 Replies

7. Shell Programming and Scripting

SED - editing file names (End of line problem?)

For lists in sed, to say what to replace, is this correct: I am hoping that this would recognise that either a "." is present, or that the substitution happens at the end of the line. For files with extensions , my script works perfectly. My problem is, files without extentions, i.e. . ... (1 Reply)
Discussion started by: busillis
1 Replies

8. UNIX for Dummies Questions & Answers

Editing problem

Hi, I want to do this: original file: a a hello e e bye becames: a hello e bye I think this can be done with sed or tr, but I've already tried all the options and can't find the solution. Thanks in advance (2 Replies)
Discussion started by: pmpx
2 Replies

9. UNIX for Dummies Questions & Answers

problem editing big file in vi

I have a big file, which vi opens it with message not sufficient space with file system. I am not adding any data in the file but changing some values within. To make these changes effective, it asks for forced write (w!), even after doing this, I see this particular record, change is not... (4 Replies)
Discussion started by: videsh77
4 Replies
Login or Register to Ask a Question