Replacement with sed
Solved
CYG
-
jipicy Posted messages 40842 Registration date Status Modérateur Last intervention -
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
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
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 :
--
Z'@+...che.
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.
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).
--
Z'@+...che.
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.
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"):
--
Z'@+...che.
sed -n 's/PROCESS\[\t\]\[\t\]M/PROCESS\t\tM/p' doris1.inand 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.
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.