Shell script: Find "\n\t..." to replace a string in a file
Can someone give me a simple bash script to find a string which includes some special characters eg "\n\t...hello world\r" in a file, and replace it with a different string?
Thank in advance. |
Crude, but may work.
Code:
echo -e "\n\tHello World\r" | tr -s "[\r\n\t]Hello World" "j" You can replace echo with cat file and pipe that into tr |
thanks jaykup. I will try it soon. Thanks
|
Quote:
|
Dear guys, I've just to tried your solution but i guessed it didnt match my need. Let me explain my problem clearly
I have a source file with a total of 15 lines(line 4,5,6,11,12,13 are empty lines)as below: Source file Code:
1: HHR _PCBCheck, , Destination file Code:
1: HHR _PCBCheckImpl, , I also define a condition file to easy for finding and replacement. Condition file: Code:
[FIND 1] step0: i=1 step1: read block text A (including empty line) from section [FIND i] in Condition file step2: find A from Souce file step3: if found, replace the text A with text in section [REPALCE i] (including empty line) in Condition file then output to Destination file step4: i=i+1 step4: back step1 while i<=n I am really want a shell script (bash or sh shell) like that and hope you take your valuable time to help me. Thanks and thanks again. |
are the line numbers in the code?
|
Quote:
|
i think you need to properly state the problem not the solution.
anyway, as I ain't busy I did some perl for you... Code:
#! /usr/local/bin/perl -wn |
Thank you so much Bigearsbilly. Finally, I solved my problem.
|
All times are GMT -5. The time now is 09:29 AM. |