Replacement with sed

Solved
CYG -  
jipicy Posted messages 40842 Registration date   Status Modérateur Last intervention   -
Hello,
I need to execute a shell command that contains a tabulation, and I don't know how to do it with Cygwin. The command is as follows:
"find sed -i 's/PROCESS M/c PROCESS M/' {} \;"
knowing that there are 2 tabulations between PROCESS and M

can someone help me

thanks in advance
CYG
Configuration: Windows 2003 Internet Explorer 6.0

4 réponses

jipicy Posted messages 40842 Registration date   Status Modérateur Last intervention   4 898
 
Hello,

Your order doesn’t make any sense ;-\

Then what do you want to do with "sed"? (in your example you want to replace "Process M" with "Process M")

Are the two tabs on the left or right side of "sed"?

P.S. Use the tags "< code >" and "</ code >" (without spaces after the opening angle brackets and before the closing angle brackets) to format text on the forum :
$ echo -e "A\t\tB" A B $ echo -e "A\tB" A B 
;-))

--

Z'@+...che.
JP : Zen, my Nuggets ! ;-) Knowledge is only valuable if it is shared.
3
CYG
 
I want to replace "<PROCESS\t\tM>" with "<c PROCESS\t\tM>" (the difference is the "c "), but now I've made a mistake, a wrong maneuver, I thought "<[\t]>" represented tabulation and as a result in my files I have "<c PROCESS[ ][ ]M>" and I don't want the brackets to show up, can you help me please?

The command is "<find . -type f -name "doris1.in" -exec sed -i 's/PROCESS[\t][\t]M/c PROCESS[\t][\t]M/' {} \;>"

Furthermore, it applied the modification to all my doris1.in files in other subdirectories; I only wanted to test the command on one file, but it applied to all the files.
0
jipicy Posted messages 40842 Registration date   Status Modérateur Last intervention   4 898
 
Generally speaking, you should never test with the switch "-i"!!! You put nothing and that way at least you see the result on the screen, or you put "-i.BAK" and it creates a backup file for you...

Could you please upload a file "doris1.in" to "cjoint" so we don't make another mistake and ensure the syntax to use (in case there are characters that you missed).
echo -e "PROCESS[\t][\t]M" | sed 's/PROCESS\[\t\]\[\t\]M/c PROCESS\t\tM/' c PROCESS M
;-))

--

Z'@+...che.
JP : Zen, my Nuggets ! ;-) Knowledge is only good if it is shared.
0
CYG
 
the file doris1.in "<a href='https://www.cjoint.com/?dds5I4dprx' target='_blank' rel='nofollow noopener noreferrer'>https://www.cjoint.com/?dds5I4dprx</a>"
0
CYG
 
For your order, where should I put the file name??
Thank you
CYG
0
jipicy Posted messages 40842 Registration date   Status Modérateur Last intervention   4 898
 
Voici la traduction demandée : Here is the first command to restore your tabs without the brackets (remove the "-n" and the final "p" if the result is good and replace it with "-i" or "-i.bak"):
sed -n 's/PROCESS\[\t\]\[\t\]M/PROCESS\t\tM/p' doris1.in
and the second to take into account the forgotten line (if it’s really a forgotten one, since there are empty spaces before the 2 tabs) above 2 others (same for this one for the "-n" and "p"):
sed -n 's/PROCESS[ ]*\t\tM/ c &/p' doris1.in
;-))

--

Z'@+...che.
JP : Zen, my Nuggets ! ;-) Knowledge is only good if it is shared.
0
CYG
 
Hello;

Thank you, your order is perfect
;)
CYG
0
jipicy Posted messages 40842 Registration date   Status Modérateur Last intervention   4 898
 
You're welcome ;-))

--

Z'@+...che.
JP : Zen, my Nuggets ! ;-) Knowledge is only good if it is shared.
0