CHANGING THE TEXT INSIDE A FILE


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting CHANGING THE TEXT INSIDE A FILE
# 1  
Old 04-09-2010
CHANGING THE TEXT INSIDE A FILE

Hi All,
I need a small help in formating a file.

I have a file with word like this;

Code:
ATGHYJIKOLFHJDHDGDYFGFYGRYGFYRHFYHFUED
DHDJFDFSJFLFJSKJFSLKJFGHDKLGLDKGLKDNVNV
VNLDVLDVDHFJDKDJVNVHSUFNHJFMVJFMVKJMFV
...
....
....

like this 75000 words.

I want to convert this words into a single column by maintaining the order.

For example,

Code:
A
T
G
H
Y
J
I
K
O
L
F
H
J
D
H
D
G
D
Y
F
G
F
Y
G
R
Y
G
F
Y
R
H
F
Y
H
F
U
E
D END OF FIRST LINE (THIS IS JUST AN INDICATOR)
D
H
D
J
F
D
F
S
J
F
L
F
J
S
K
J
F
S
L
K
J
F
G
H
D
K
L
G
L
D
K
G
L
K
D
N
V
N
V     END OF SECOND LINE
V
N
L
D
V
L
D
V
D
H
F
J
D
K
D
J
V
N
V
H
S
U
F
N
H
J
F
M
V
J
F
M
V
K
J
M
F
V  END OF THIRD LINE
..
...

IS THERE A BEST WAY TO DO IT USING AWK OR SED OR UNIX COMMANDS.
ITS BASICALLY MAKING A MATRIX INTO A LONG VECTOR.

PLEASE LET ME KNOW
# 2  
Old 04-09-2010
Code:
sed "s/./&\\
/g;s/.$//" file > newfile

Code:
awk ' { gsub(".","&\n");sub(".$","") } 1 ' file > newfile


Last edited by anbu23; 04-09-2010 at 04:05 PM..
# 3  
Old 04-09-2010
I tried it. but got the following error message

Code:
tr -d '\n' < D.txt | sed "s/ ./&\\/g" > newfile
sed: 1: "s/ ./&\/g": unterminated substitute in regular expression

Please let me know whats happening
# 4  
Old 04-09-2010
Sed Command has to be in multiple lines
# 5  
Old 04-09-2010
Thanks,

The awk command worked
# 6  
Old 04-09-2010
Or, you guys could use a command specifically designed for this job Smilie
Code:
fold -w1 file

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy and paste text inside a xml file

I have a really big XML file. I need copy the value of one tag inside another one tag. I try to publish one example. <channel update="i" site="merge-xmltv" site_id="" xmltv_id="Rai 1">Rai 1</channel> <channel update="i" site="merge-xmltv" site_id="" xmltv_id="Rai 1 +2HD">Rai 1... (6 Replies)
Discussion started by: Tapiocapioca
6 Replies

2. Shell Programming and Scripting

Help with changing text file layout

Hi there, I am with this one column input text file to change layout, please help. Thanks. I have awk, sed. $ cat input Median 1.0 2.3 3.0 Median 35.0 26.3 45.7 10.1 63.1 Median 1.2 2.3 (8 Replies)
Discussion started by: cwzkevin
8 Replies

3. UNIX for Dummies Questions & Answers

Changing text in multiple files, but with different text for each file

Hello, I have a situation where I want to change a line of text in multiple files, but the problem is that I want to change the text to something unique for each file. For example, let's say I have five files named bob.txt, joe.txt, john.txt, tom.txt, and zach.txt. Each of these files has a... (5 Replies)
Discussion started by: Scatterbrain26
5 Replies

4. Homework & Coursework Questions

copy files inside a text file

Hi Guys , I am new to this and Hi to all ,Need your help I am trying to copy Files which are inside file.txt The files inside file.txt are inthe below order file1.log file2.log file3.log ....... I want to copy these files to an output Directory , Please help (1 Reply)
Discussion started by: hc17972
1 Replies

5. Homework & Coursework Questions

copy files inside a text file

Hi Guys , I am new to this and Hi to all ,Need your help I am trying to copy Files which are inside file.txt The files inside file.txt are inthe below order file1.log file2.log file3.log ....... I want to copy these files to an output Directory , Please help (1 Reply)
Discussion started by: hc17972
1 Replies

6. Shell Programming and Scripting

Last modified time of the folder is changing when I view the file inside the directory

Hi., Last modified time of the folder is changing when I view the file inside the directory. Here is the test on sample directory. I believe that ls -l commands gives the time detail w.r.t last modified time. Pl. suggest. bash-3.2$ mkdir test bash-3.2$ cd test bash-3.2$ touch myfile.txt... (2 Replies)
Discussion started by: IND123
2 Replies

7. Shell Programming and Scripting

Changing a text file

I have a file as below and want to change it using awk I want to find the entries such as Iteration No.788 Best Value 0.00408152 Next-Worst Value 0.00522935 Worst Value 0.00523487 and change it to Iteration No.788 788. Best Value = 0.00408152 788. ... (8 Replies)
Discussion started by: kristinu
8 Replies

8. Shell Programming and Scripting

pattern replace inside text file using sed

Hi, I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file. For Example: If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained. But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Discussion started by: meharo
4 Replies

9. Shell Programming and Scripting

Changing the text file format

Hi, I have a shell script to unload all the empname who have salary >50000 from the emp table into a text file(empname.txt) . m_db unload "$dbc_file" -column_delimiter ',' -select "SELECT empname FROM emp where salary > 50000" >> empname.txt Now my text file have data in the following format ... (3 Replies)
Discussion started by: kavithakuttyk
3 Replies

10. UNIX for Dummies Questions & Answers

finding text inside file

Hi everyone I have a small problem i cant find a soloution to... I'm using digital unix and have to find out all the files which have a certain string inside them and i dont know how to do it. *This search is done as root. *All files from '/' to the last directory should be searched for... (3 Replies)
Discussion started by: dindan100
3 Replies
Login or Register to Ask a Question