Sed Newbie Question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sed Newbie Question
# 8  
Old 05-26-2011
Thanks for still trying to help

I tried both of them but when it runs from cmd i get a lot of
Code:
♥Ω♥μ♥  Σ♥δ♥Χ♥η♥Σ♥ζ♥Φ♥κ♥θ♥μ♥                    |   | ο♥θ♥ξ♥κ♥ζ♥Σ♥κ♥Ω♥μ♥  Σ♥δ♥Χ♥η♥Σ♥ζ♥Φ♥κ♥θ♥μ♥                    |   | Χ♥δ♥. Τ♥Χ♥ζ♥β♥Ψ♥Χ♥δ♥θ♥ξ♥  1 9 9         |
   | δ♥β♥ε♥Χ♥ζ♥Σ♥μ♥  π♥Χ♥κ♥μ♥θ♥ζ♥Ω♥|   | 7 0 0 1 4 |   | 1 0 0 |
 1 | 5 0 4 0 | 4 4 3 2 0 0 0 | 0 | 0 4 / 0 5 / 2 0 1 1   1 2 : 0 0 | 0 4 / 1 0 / 2 0 1 1   1 2 : 0 0 | 1 0 / 0 5 / 2 0 1 1   1 2 : 0 0 |   |   | ν♥β♥Ω♥7 6 8 7
     |   | 0 0 |   | ε♥θ♥ν♥- ν♥θ♥  Χ♥ζ♥θ♥β♥γ♥β♥Σ♥Ψ♥θ♥ε♥Χ♥ζ♥θ♥                                    |   | 0 0 |   | Z H E N J I A N   J M |   |   | # ο♥θ♥ξ♥κ♥ζ♥Σ♥κ
♥Ω♥μ♥  Σ♥δ♥Χ♥η♥Σ♥ζ♥Φ♥κ♥θ♥μ♥                    |   | ο♥θ♥ξ♥κ♥ζ♥Σ♥κ♥Ω♥μ♥  Σ♥δ♥Χ♥η♥Σ♥ζ♥Φ♥κ♥θ♥μ♥                    |   | Χ♥δ♥. Τ♥Χ♥ζ♥β♥Ψ♥Χ♥δ♥θ♥ξ♥  1 9 9

and doesn't work. I run it like this
Code:
E:\sed s/\([^[:digit:]]\):/\1./g PLHSMB-new.TXT

Am i doing something wrong?

---------- Post updated at 07:06 AM ---------- Previous update was at 06:57 AM ----------

EDIT: If i run it with a single a single line from my txt file it seems that it changes it but it's doesn't keep the change inside the file. I mean that i see the change in command line but not when i open the txt

---------- Post updated at 07:15 AM ---------- Previous update was at 07:06 AM ----------

EDIT2 : Nope, i can't make it to work. When i run my txt with one line only for testing like this
Code:
E:\test>sed "s/\([^[:digit:]]\):/\1./g" PLHSMB-new.TXT

from cmd i get the following output.
Code:
 ■2 | 5 0 4 0 | 0 0 1 6 6 2 7 | 0 | 0 7 / 0 5 / 2 0 1 1   1 2 . 0 0 | 0 7 / 1 1 / 2 0 1 1   1 2 . 0 0 | 0 1 / 0 5 / 2 0 1 1   1 2 . 0 0 |   | Σ♥Ψ♥. Σ♥Τ♥

Two problems with the above, first as i told it's not saved inside the file and more importanly as you can see it also changes 12:00 to 12.00.

I' stuck
# 9  
Old 05-26-2011
Give a try to something like:

Code:
E:\test>sed "s/\([^0-9]\):/\1./g" PLHSMB-new.TXT >>output.txt

---------- Post updated at 03:11 PM ---------- Previous update was at 03:05 PM ----------

OOOOOOOooooooooooooooooh ...
Are all your character separated with space ?????
the code i provide would work for
Code:
12:00 AB:CD

but it would NOT work for
Code:
1 2 : 0 0  A B : C D

if all character are space-separated then you should give a try to this (add a spce after the closing square bracket "]":
Code:
sed "s/\([^0-9] \):/\1./g" PLHSMB-new.TXT

# 10  
Old 05-26-2011
I'm getting a result after some test and i could really need your opinion. This txt that i'm trying to remane has 60.000 records. I took 2 of them in a new file and i run yur command. It seems to have this result and tell me if it is my fault or something has to be changed for the command to work.
I have the following lines
Code:
07/05/2011 12:00|07/11/2011 12:00|#ΠΑΠΑΣ ΠΑΠΑΣ|
25/11/2011 12:00|01/05/2011 12:00|#ΟΔ:ΕΥΑΓ|

Now when i give the command
Code:
sed "s/\([^[:digit:]]\):/\1./g" PLHSMB.TXT >PLHSMB1.TXT

I get a new file and this is what happens
Code:
07/05/2011 12.00|07/11/2011 12.00|#ΠΑΠΑΣ ΠΑΠΑΣ|
25/11/2011 12:00|01/05/2011 12:00|#ΟΔ.ΕΥΑΓ|

As you can see it changes 12:00 to 12.00 at the first line which is wrong and at the second is works correctly! Do you have any idea what's wrong?

thanks again

EDIT:I was writing the post when you answered so i'll read and post back again
# 11  
Old 05-26-2011
As far as i have tested, for me it works fine :
Code:
[ctsgnb@shell ~/sand]$ cat tst
07/05/2011 12:00|07/11/2011 12:00|#ΠΑΠΑΣ ΠΑΠΑΣ|
25/11/2011 12:00|01/05/2011 12:00|#ΟΔ:ΕΥΑΓ|
[ctsgnb@shell ~/sand]$ sed 's/\([^0-9]\):/\1./g' tst
07/05/2011 12:00|07/11/2011 12:00|#ΠΑΠΑΣ ΠΑΠΑΣ|
25/11/2011 12:00|01/05/2011 12:00|#ΟΔ.ΕΥΑΓ|
[ctsgnb@shell ~/sand]$

---------- Post updated at 03:18 PM ---------- Previous update was at 03:16 PM ----------

Also worked with digit class :
Code:
[ctsgnb@shell ~/sand]$ cat tst
07/05/2011 12:00|07/11/2011 12:00|#ΠΑΠΑΣ ΠΑΠΑΣ|
25/11/2011 12:00|01/05/2011 12:00|#ΟΔ:ΕΥΑΓ|
[ctsgnb@shell ~/sand]$ sed 's/\([^[:digit:]]\):/\1./g' tst
07/05/2011 12:00|07/11/2011 12:00|#ΠΑΠΑΣ ΠΑΠΑΣ|
25/11/2011 12:00|01/05/2011 12:00|#ΟΔ.ΕΥΑΓ|
[ctsgnb@shell ~/sand]$ sed 's/\([^[:digit:]]\):/\1./g' tst >tst.tmp
[ctsgnb@shell ~/sand]$ cat tst.tmp >tst
[ctsgnb@shell ~/sand]$ cat tst
07/05/2011 12:00|07/11/2011 12:00|#ΠΑΠΑΣ ΠΑΠΑΣ|
25/11/2011 12:00|01/05/2011 12:00|#ΟΔ.ΕΥΑΓ|
[ctsgnb@shell ~/sand]$

# 12  
Old 05-26-2011
Hi and thanks once more

This what i've managed until now. I have to say that i'm using sed from a UniPack in Windows cause i'm at work so i don't know if it's working correctly.

After some time working to fix my problem i can run from cmd
Code:
sed "s/\([^[:digit:]]\):/\1./g" tst.txt >tss.txt

It's working but it ruins the lines.i get this
Code:
07/05/2011 12:00|07/11/2011 12:00|#ΠΑΠΑΣ ΠΑΠΑΣ|25/11/2011 12:00|01/05/2011 12:00|#ΟΔ.ΕΥΑΓ|

It's close but yet not enough

I hope you still follow the post, thanks
# 13  
Old 05-26-2011
Windows is so unpredictable ...
did you try to open the generated "tss.txt" file into the Wordpad ?
# 14  
Old 05-26-2011
I agree about windows but i can't do anything else for now. I opened it with both notepad++ and ultraedit but i'll try wordpad also. Or else i'll test in my home linux to be sure

Thanks a lot for the time
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed newbie question

hi all: i am trying to use sed to separate hex bytes "363834574e292c20" to "36 38 34 57 4e 29 2c 20". i used the following script (googled) and i got "3 63 83 45 74 e2 92 c2 0". how could i modify the script to meet my needs? thanks (8 Replies)
Discussion started by: ipfreak
8 Replies

2. Shell Programming and Scripting

What does this do (newbie question)...

I was looking through some code online and came accross this... ls *.txt | grep text1 | cat file1 – file2 | `echo wc –l` I know what "ls|grep text1" does and I know a word count gets echoed but beyond that I am confused. Please use layman terms as much as possible as I am a newbie. (8 Replies)
Discussion started by: elohssa
8 Replies

3. UNIX for Dummies Questions & Answers

newbie question

Hi all, I am sure this is very simple but I cant quite get it. I am trying to search textfile1.txt for a string then take the results of the search and append the result to textfile3.txt So far I have used $ find file1.txt -exec grep "string i am looking for" '{}' \; -print this... (2 Replies)
Discussion started by: radgator
2 Replies

4. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

5. UNIX for Dummies Questions & Answers

UNIX newbie NEWBIE question!

Hello everyone, Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware. I hope I am not missing anything! :p (4 Replies)
Discussion started by: Hanamachi
4 Replies

6. Shell Programming and Scripting

SED question: newbie here.

Hello... I wanted to figure out how to remove the 1st instance of a comma from a file.. 100+ line file ------------- 'test1' ,'dudes are cool' <-- remove comma from first instance of comma in file ,'cool dude' ,'bbbbbb' I tried everything from cat jigar|tr , >1.txt to cat jigar|sed... (2 Replies)
Discussion started by: jigarlakhani
2 Replies

7. UNIX for Dummies Questions & Answers

Newbie question?

What is the best way to learn UNIX on the web, with out buying books? any link would be much help. Thank you in advance, L (1 Reply)
Discussion started by: lsoria1
1 Replies

8. UNIX for Dummies Questions & Answers

newbie question

I am taking a db classes toward oracle 10g. I am taking unix as well . I need to know what is the best option for os . should I use linux fedora. or get a sun box and start learning from there. Thanks (6 Replies)
Discussion started by: xzyan
6 Replies

9. Shell Programming and Scripting

newbie question

hey all, I have repeatedly seen scripts containing the following syntax, grep "hello" $myfile >> $log 2>&1 can anyone explain exactly what "2>&1" mean? THANK YOU (4 Replies)
Discussion started by: mpang_
4 Replies

10. UNIX for Dummies Questions & Answers

Very new newbie question

sorry if im not asking inthe right spot but, how do you turn the beeping off every time you hit a key onthe keyboard. I tried the click -n but it told me it didnt recognize click any help would be greatly appreciated ( the beeping is not going over well in the surrounding cubicles) thank you... (4 Replies)
Discussion started by: Split100
4 Replies
Login or Register to Ask a Question