replacing enter character in LINUX


 
Thread Tools Search this Thread
Operating Systems Linux replacing enter character in LINUX
# 1  
Old 09-22-2008
Bug replacing enter character in LINUX

Hi

1) I need to replace an "enter" character with another character.
I thought it should be like this (E.G)
replace all stirngs "LIAV"+enter with kokokoko:

:1,$s/LIAV^M/kokokoko/g

but it dose not work.

2) Also dose nayone know how to replace wildcards?
for example if the file looks like this
ABCDEF
AAAAA
ABBBCC
FFFFFF
FAFFFF

and I want to replace all stirngs that has "F<unknown char>F" so it will replace the last 2 lines.


Thanks :-)
Liav

Last edited by liav; 09-22-2008 at 12:08 PM..
# 2  
Old 09-22-2008
Hi Following:

tr -d '\012'

This will delete the Enter( New Line ) Characters.

So something like:

cat file1 | tr -d '\012' > file2

cheers,
RK....
# 3  
Old 09-22-2008
F....F problem
Code:
sed 's/^F.*F$/replacment text/'  oldfile > newfile

I think you have DOS (windows) files with the "^M" in them right? dos2ux or sometimes called dos2unix will fix that

both problems together

Code:
dos2ux myfile | sed sed 's/^F.*F$/replacment text/' > newfile

# 4  
Old 09-23-2008
Thanks guys :-)

Thanks Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search and recursively enter new line after Nth character

Hi All, My file is a string of around 50K character. I'm trying to insert new line after every 320 character in my file. I know the command to insert newline, but problem is I'm not able to search 320th position. Please advice. (6 Replies)
Discussion started by: Amit786
6 Replies

2. Shell Programming and Scripting

How to pass enter key or selected character in bash script?

hi, i've bash script thats working... but now i need to add a line....that prompts for user input....like yes and 1 as complete install.... so here's how it looks... $ cd 9200 (cd into directory) $./install (hv to type ./install to run install then ask for) ----do you want to... (4 Replies)
Discussion started by: kernel11
4 Replies

3. Shell Programming and Scripting

replacing by newline character

I have a file (pema)with a single long record which i have to break up into multiple lines Input s1aaaaaaaaaaaaaaaaaaaaaaas1bbbbbbbbbbs1cccccccccc Output s1aaaaaaaaaaaaaaaaaaaaaaa s1bbbbbbbbbb s1cccccccccc m planning to do it by replacing s1 by \ns1 \n is the new line character i... (5 Replies)
Discussion started by: pema.yozer
5 Replies

4. UNIX for Dummies Questions & Answers

replacing a character

Hi All, contents of my file is like this: xxx xxx1 N N N 0 yyy yyy1 Y N N 0 i want to replace 1st N of xxx xxx1 N N N 0 line with Y. i. e i want the output like this: xxx xxx1 Y N N 0 how can i do this? please help. Thanks (8 Replies)
Discussion started by: Usha Shastri
8 Replies

5. UNIX for Dummies Questions & Answers

replacing 1 character with many : tr

Hi All, I would like to know how, iff at all we can, we may use the 'tr' command to replace a single character with multiple characters. eg: if i have a string valued "him", how can i use 'tr' to replace 'i' with "oo" to make "hoom". Just replacing a single character by many. tried:-... (16 Replies)
Discussion started by: hkansal
16 Replies

6. Shell Programming and Scripting

replacing a character with another

hi i have a file and reading line by line, i need to replace 8-15 and 18-27 charaters with character 'x'. Eg: satyasatxxxxxxxsatxxxxxxxxxtyasatyasatyasatyasatyasatya please help thanks Satya (1 Reply)
Discussion started by: Satyak
1 Replies

7. Shell Programming and Scripting

Enter Crtl+U character in shell script

hi I have some program which accepts "Crtl+U" input, Now i want to run it thorugh my written script ...all other inputs are accepted but how to supply this input. I am supplying input parameters to the program named EX as below. ================================= main.sh . . EX<<EOF... (3 Replies)
Discussion started by: ashish_uiit
3 Replies

8. UNIX for Dummies Questions & Answers

Replacing the last character

Hi , I need to change the last character of the line: ie: input file: (raj, muthu, mani, Output: (raj, muthu, mani); so i need to change the last comma by the closing braces so help me out in the issue. Thanks in advance. (2 Replies)
Discussion started by: ithirak17
2 Replies

9. UNIX for Dummies Questions & Answers

How can i enter to another system using linux...

I m using linux os...and my friend using windows....we both having internet connection...Is there any possible to enter his system from my system using this internet connection..... (1 Reply)
Discussion started by: stalin2020
1 Replies

10. Shell Programming and Scripting

HELP with Enter Character

I'm using PHP in my site. I have txt files for news. I reads the txt files and post the news. i have a php function that finds the caracter asc(13) which is the enter, and puts a <br>. It works in Windows, but not on Unix. Can u help me with that. Thanks (1 Reply)
Discussion started by: zecarlos
1 Replies
Login or Register to Ask a Question