sed or awk


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 8  
Hi ghostdog & everyone,

Have been trying variations of:

Code:
sed '/^user/ c /user **** ****/ ' ${BATCHFILE} > ${BATCHFILE}.tmp
mv ${BATCHFILE}.tmp > ${BATCHFILE}

sed '/^user/ c \"user **** ****\" ' ${BATCHFILE} > ${BATCHFILE}.tmp

With as yet no success. Returns the following:

sed: Function /^user/ c /user **** ****/ cannot be parsed.

Sorry, but how do you guys do it ?? Smilie

Last edited by Cameron; 10-01-2007 at 02:52 AM.. Reason: my bad - typo.
# 9  
Code:
sed -e "s/^user.*/user **** ****/g" input.txt > input.txt.masked
mv input.txt.masked input.txt

# 10  
Vino,
Many thanks for the ultra quick reply & your assist. Smilie
I take it that the period [.] in '.*' has special significance ?

I didn't realise that I could perform a substitute like that.

Cheers,
Cameron
# 11  
Quote:
Originally Posted by Cameron
I take it that the period [.] in '.*' has special significance ?
In the sed world, you can consider . as a placeholder for any character. And a .* would stand for any combination of characters.
# 12  
Many thanks again Vino for the quick reply and the small lesson in 'sed' Smilie

Cheers,
Cameron
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #73
Difficulty: Easy
BSD (Berkeley Software Distribution) is an open-source, Unix-like operating system.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

2. Shell Programming and Scripting

Help on sed/awk

hello, I have been working on extracting a report in Unix and stuck on the following. The file contents are as follows and I would like to do the following ================================================================================ Autootaal ... (3 Replies)
Discussion started by: rakeshv
3 Replies

3. UNIX for Dummies Questions & Answers

sed/awk or help please

I have a file that contain the data below: B1 1 2 3 B2 20 30 40 B3 7 8 B4 100 B5 21 22 23How can I retrieve the data for B1 into a seperate file. (8 Replies)
Discussion started by: bobo
8 Replies

4. Shell Programming and Scripting

help with sed or awk

I need to add a field at the beginning of each record in the file. The file is comma seperated. Can somebody throw some light. My record looks something like this I need to add 100 at the beginning of each record. o/p should be (2 Replies)
Discussion started by: dsravan
2 Replies

5. Shell Programming and Scripting

awk and sed

awk and sed anyone? sample: server2 /sbin/powermt display|grep -E "failed|degraded" > server3 /sbin/powermt display|grep -E "failed|degraded" > output: server2 'hostname;/sbin/powermt display|grep -E "failed|degraded"' > server3 'hostname;/sbin/powermt display|grep -E... (2 Replies)
Discussion started by: invinzin21
2 Replies

6. Shell Programming and Scripting

What to use : awk or sed

Hi All, I am a bit confused,Can anyone help; My problem is that i have a flat file in this format 8.10 USAccountSummaryClone1 3.10 USAccountSummaryClone2 2.80 GlobalUserManagementClone1 2.10 BasicServicesClone2 1.60 MYCAServicesClone2 1.30 INTLEStatementClone1 0.90... (6 Replies)
Discussion started by: usha rao
6 Replies

7. Shell Programming and Scripting

awk and sed-- need help

Hi All, Needa little help with sed and awk. I have a file which contains password, Following is the sample: <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="role1" password="tomcat" roles="role1"/> <user username="both" password="tomcat"... (7 Replies)
Discussion started by: nua7
7 Replies

8. UNIX for Advanced & Expert Users

sed in awk ? or nested awk ?

Hey all, Can I put sed command inside the awk action ?? If not then can i do grep in the awk action ?? For ex: awk '$1=="174" { ppid=($2) ; sed -n '/$ppid/p' tempfind.txt ; }' tempfind.txt Assume: 174 is string. Assume: tempfind.txt is used for awk and sed both. tempfind.txt... (11 Replies)
Discussion started by: varungupta
11 Replies

9. UNIX for Dummies Questions & Answers

sed/awk help

I'm new for sed/awk. please help: If I have a passing parameter like "aa_bbb_ccc", how can I only catch the string "bbb", because I only need this part to asign to another variable. Thanks (10 Replies)
Discussion started by: ting123
10 Replies

10. Shell Programming and Scripting

sed in awk

Hi there, I'm trying to process a comma delimited file to remove the seconds: 916901,0,488589834,TRADE,Trade, ,2002-07-2510:14:43.387,CITI.MW,970847, , , ,808.0,2526.0,0.0,0.0,-1 So basically the .*** from the 7th field Any help appreciated Jon (4 Replies)
Discussion started by: orange_one
4 Replies

Featured Tech Videos