File editing question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers File editing question
# 1  
Old 12-20-2006
File editing question

I have following simple file called testing.txt

...
key1=value1,key2=value2,key3=value3 ... and so on

I am trying to change it to

key1=value1
key2=value2
key3=value3

I tried to use following code

sed 's/,/\n/g' testing.txt > temp.txt && mv temp.txt testing.txt

Yet, what I am getting is
key1=value1nkey2=value2nkey3=value3n ....

I thought that '\n' is the end of line characters. I guess I can not use it.
Any ideas?
# 2  
Old 12-20-2006
$ tr ',' '\n' < testing.txt > newfile.txt && mv newfile.txt testing.txt
$ cat testing.txt
key1=value1
key2=value2
key3=value3
# 3  
Old 12-20-2006
it worked. thank you very much
# 4  
Old 12-21-2006
Quote:
Originally Posted by arushunter
I have following simple file called testing.txt

...
key1=value1,key2=value2,key3=value3 ... and so on

I am trying to change it to

key1=value1
key2=value2
key3=value3

I tried to use following code

sed 's/,/\n/g' testing.txt > temp.txt && mv temp.txt testing.txt

Yet, what I am getting is
key1=value1nkey2=value2nkey3=value3n ....

I thought that '\n' is the end of line characters. I guess I can not use it.
Any ideas?
\n works with some version of sed.
Try this
Code:
echo "key1=value1,key2=value2,key3=value3 " |
sed "s/,/\\
/g"

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 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

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

3. Shell Programming and Scripting

File Editing

Never mind!. Thanks (1 Reply)
Discussion started by: smarones
1 Replies

4. Shell Programming and Scripting

editing line in text file adding number to value in file

I have a text file that has data like: Data "12345#22" Fred ID 12345 Age 45 Wilma Dino Data "123#22" Tarzan ID 123 Age 33 Jane I need to figure out a way of adding 1,000,000 to the specific lines (always same format) in the file, so it becomes: Data "1012345#22" Fred ID... (16 Replies)
Discussion started by: say170
16 Replies

5. Shell Programming and Scripting

Help with file editing while keeping file format intact

Hi, I am having a file which is fix length and comma seperated. And I want to replace values for one column. I am reading file line by line in variable $LINE and then replacing the string. Problem is after changing value and writing new file temp5.txt, formating of original file is getting... (8 Replies)
Discussion started by: Mruda
8 Replies

6. Shell Programming and Scripting

Question on vi editing

If I have a text file which I am editing with vi and I perform the following editing. :1,$s/\<green\>/blue/g Later I decide to replace all ocurance of blue to red, then instead of writing the above editing line is there a way to recall it and work on it, instead of repeating the entire editing... (1 Reply)
Discussion started by: Tirmazi
1 Replies

7. Shell Programming and Scripting

editing a file

Hi i have a file name as file1 which has Following content: ROLLOVER_INTERVAL=0 OUTPUT_DIR_COUNT=MULTIPLE FILETYPE=XmlExporter i want to change the FILETYPE=recordexport can any one pls help me on this 2nd query: i want to change OUTPUT_DIR_COUNT=MULTIPLE as ... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

8. Linux

file editing

I have created a file with vi -x (file name) this is encrypted file when i again open this file it ask me to enter a password before editing it.Can i remove this password but i don't want to delete a file how to do this. Thanks (0 Replies)
Discussion started by: ambavaram
0 Replies

9. Shell Programming and Scripting

Help with editing file

I have a file of 100000 records. This file is created by concatenation of two files. I want to edit this file from record number 80,000 till the end and add "|N" for each record . How can I acheive this. Please suggest (4 Replies)
Discussion started by: dsravan
4 Replies

10. UNIX for Advanced & Expert Users

Editing the end of the file without loading the entire file

hi! I am a newbee. I would really appreciate if you can answer the following question: I have a huge data file, 214MB with several coloumns. I need to delete the very last line of the file. Everything I know takes a lot of time to do it ( because I have to open the file in an editor or run a... (3 Replies)
Discussion started by: Garuda
3 Replies
Login or Register to Ask a Question