sed formatting query


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed formatting query
# 1  
Old 05-09-2007
sed formatting query

hi

i have to modify a number accross a file
for example in the following file

name - abc
age 20
name - def
age 25
name - pqr
age 54
name - xyz
age 32

i want the number against all age to be say 50. like this


name - abc
age 50
name - def
age 50
name - pqr
age 50
name - xyz
age 50

plz hlp....
# 2  
Old 05-09-2007
Code:
sed 's/^age .*/age 50/' myFile

# 3  
Old 05-09-2007
Code:
awk '{ if( $0 ~ "^age" ) { print "age 50" } else { print } }' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SQL Query in Shell Script output formatting

Hi All, #!/bin/ksh call_sql () { sql=$1 sqlplus -s $sqlparam_sieb <<EOF SET ECHO OFF; SET NEWPAGE NONE; SET SQLBL OFF; SET VERIFY OFF; SET LINESIZE 2000; SET... (2 Replies)
Discussion started by: Kevin Tivoli
2 Replies

2. Shell Programming and Scripting

Problem in formatting output of SQL query in excel sheet in shell script

Hi Guys.. Need your help to format the output of my shell script. I am using spool command to take out put in csv file. below is my code. (for example) col USERNAME for a15 col EMAIL for a30 col FULL_NAME for a20 col LAST_LOGIN for a40 col DATE_CREATED for a40 SPOOL 120.csv... (3 Replies)
Discussion started by: Agupte
3 Replies

3. Shell Programming and Scripting

Formatting the query output using shell script

Hi All, I'm finding it difficult to format the query output that was returned in a shell script. Actually i have one shell script which does some DB stuff and depending on the result it will do some more tasks. My question here is to format the query output returned by mysql. Intitally my... (5 Replies)
Discussion started by: RSC1985
5 Replies

4. Shell Programming and Scripting

Space formatting issue in sed

How to remove any space around a specific charachter from a string using sed. for exmple : the string is like following str1='"name", "roll", "addr","job", "pay",' I need to remove all the spaces aronnd the commas. (8 Replies)
Discussion started by: mady135
8 Replies

5. Shell Programming and Scripting

Formatting help needed awk or sed maybe

I am executing the following command: sort file1.txt | uniq -c | sort -n > file2.txt The problem is that in file 2, I get leading spaces, Like so: 1 N/A|A8MW11 8 N/A|ufwo1 9 N/A|a8mw11 10 900003|smoketest297688 10 N/A|a9dg4 10 danny|danni 12... (5 Replies)
Discussion started by: ddurden7
5 Replies

6. Shell Programming and Scripting

Formatting Help needed(Sed)

I have a file called abc.txt which has following contents. 10.180.8.231=31608 10.180.8.232=29011 10.180.8.233=31606 10.180.8.234=40501 10.180.8.235=32591 10.180.8.236=31605 10.180.8.237=30561 10.180.8.238=14231 How would i find a ip address having maximum number of ram available. Here... (2 Replies)
Discussion started by: pinga123
2 Replies

7. Shell Programming and Scripting

formatting data file with awk or sed

Hi, I have a (quite large) data file which looks like: _____________ header part.. more header part.. x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 ... ... x59 x60 y1 y2 y3 y4... ... y100 ______________ where x1, x2,...,x60 and y1, y2,...y100 are numbers of 10 digits (so each line... (5 Replies)
Discussion started by: lego
5 Replies

8. Shell Programming and Scripting

Noob, script formatting query

Hi all, im new to the forums and i hope im not asking a heavily posted Q but here goes. I use the following script to do a simple calculation, the problem is, the data i receive is in the form of numbers with commas i.e. 1,000,000 This code below wont recognise the commas so i have to remove... (2 Replies)
Discussion started by: benjo
2 Replies

9. Shell Programming and Scripting

sed formatting query

had asked this earlier , but now with some small modification. i wish to remove "#" characters and replace them with a single # character. how to do that? . like # should be appended in all lines ex if the file is like ####aasd ##pqr #qwert poppy output shud be #aasd #pqr #qwert... (2 Replies)
Discussion started by: gopsman
2 Replies

10. Shell Programming and Scripting

sed formatting query2

i wish to remove "#" characters and replace them with a single # character. how to do that? ex if the file is like ####aasd ##pqr ###pqr #qwert output shud be #aasd #pqr #pqr #qwert plz hlp (4 Replies)
Discussion started by: gopsman
4 Replies
Login or Register to Ask a Question