Trouble with search and substitute


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Trouble with search and substitute
# 1  
Old 09-30-2008
Trouble with search and substitute

Hi there,
I have a file with 1800+ lines and all are something like this:

drwx--x--x 12960 4096 Oct 6 2006 palfvoet
drwx--x--x 67205 4096 May 9 05:21 pallsopp
drwx--x--x palmgren 4096 Oct 6 2006 palmgren

now, as you can see, the middle one shows a time instead of a year, and every line in the file that has this needs to be marked with a * at the end of the line

I tried something like this:
/\:/,$s/.$/&*/g
but he just changed every line after the first one with a :

Anyone knows what I'm doing wrong?

PS: I'm using vi to edit this file
# 2  
Old 09-30-2008
Why don't you simply use an output format which displays unambiguous machine-readable times to begin with? Maybe recreating the file in a more useful format is not an option, though.
# 3  
Old 09-30-2008
I'm new to unix and this is just an exercise.
substitution and searching are the only things we've seen thus far.
# 4  
Old 09-30-2008
You are mixing the range /:/,$ "lines in the range between the first colon and the end of file" with the range /:/ "any line containing a colon".
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[Solved] Having trouble with simple grep search

I have a text file (allWords.txt), that I would like to search through. Here is a snippet of what it looks like... a aah aahed aahing aahs aardvark aardvarks aardwolf ab abaci aback abacus abacuses abaft ...... I would like to use the grep search to search, line by line, for... (8 Replies)
Discussion started by: blackvelvet
8 Replies

2. Shell Programming and Scripting

HELP WITH SEARCH AND SUBSTITUTE IN "|" DELIMITED FILE

Hi I have a "|" delimited file as shown below. 55987|2011-04-07|09:30: 8.0|09:30:27.4|9194 55988|2011-04 07|09:30:21.0|09:30:27.4|9199 55989|2011-04-07|09:30:25.0|09:30:27.5|9176 55990|2011-04-07|09:29:33.0|09:30:27.5|9196 55991|2011-04-07|09:30:21.0|09:30:27.5|9199... (3 Replies)
Discussion started by: alok3141
3 Replies

3. UNIX for Dummies Questions & Answers

Substitute in VI

Hi there, i am updating a file on UNIX and have many lines as per below : listen:x:37:4:Network Admin:/usr/net/nls: i would like to substitute from the :/usr to the end of the line. so at the moment im using this : :s/"\/$/ /g but i get an error.can anyone help? thank you (3 Replies)
Discussion started by: brian112
3 Replies

4. UNIX for Dummies Questions & Answers

substitute (')

I usually use : Code: awk '{gsub(/xxx/,"yyy");print}' to substitute xxx with yyy. I have a problem substitute an expression like Code: x ' y Because of the ( ' ) Any idea on how to get over this problem? Thanks (2 Replies)
Discussion started by: cosmologist
2 Replies

5. Shell Programming and Scripting

sed doubt - search and substitute string from variable.

hi, trying to learn more abt sed :( i want to substitute a variable(a) with other variable(b) appended. Read.txt contains: home/test2/abc home/test/root1 input.txt contains: make test "home/test1/none"version="1.3" wt's wrong test "home/test2/abc"version="1.0" make save... (9 Replies)
Discussion started by: dragon.1431
9 Replies

6. Shell Programming and Scripting

vi substitute

My question is how would I substitute for ceratain number of occurences in a line? If this is my input rjohns BFSTDBS01 Standard Silver NPRO30DINCR 2 Client Is it possible to change the first 3 occurences of space " " to a comma? (7 Replies)
Discussion started by: reggiej
7 Replies

7. Shell Programming and Scripting

Search and Substitute from 2 files

Hello, I am not a frequent user of Unix. With my little knowledge and some scrambling I was able to get to this point .. please help me get this right. I have 2 files file1.txt 123AAAAA111111111111111 456BBBBBB222222222222222222 789CCCCC33333333333333333 file2.txt AAAAA11111... (7 Replies)
Discussion started by: b328b
7 Replies

8. Shell Programming and Scripting

How to substitute?

Hi, I have query terms like this: a) apple bannana b) apple bannana AND chickko c) "milk shake" OR Graphes orange whereever there is space substitue with AND operator. I tried like this: (2 Replies)
Discussion started by: vanitham
2 Replies

9. Linux

Substitute for echo

Hi guys, Is there another function i could use to print out an output beside using echo? (1 Reply)
Discussion started by: hanyou.lin
1 Replies

10. UNIX for Dummies Questions & Answers

Substitute in vi

I know in vi you can do :%s/replaceme/withthis/ but if i want to find all lines say without a # at the begining and I want to put it in how would that command be formatted? I can't figure it out for the life of me. #comment blah1 hey1 grrr1 #comment #blah1 #hey1 #grrr1 (5 Replies)
Discussion started by: kingdbag
5 Replies
Login or Register to Ask a Question