hocheeming
asked on
SED command
Hi,
When I run this:
echo 1_2_spell.xml | sed 's/\([^\_]*\)\_\([^\_]*\.x ml\)/\1.\2 /'
I got the result :
1_2.spell.xml
How do I change the sed command switches to make it come out with:
1.2_spell.xml
instead?
Thanks.
CM
When I run this:
echo 1_2_spell.xml | sed 's/\([^\_]*\)\_\([^\_]*\.x
I got the result :
1_2.spell.xml
How do I change the sed command switches to make it come out with:
1.2_spell.xml
instead?
Thanks.
CM
Not sure what you are trying to do here?
But this works:
echo 1_2_spell.xml | sed 's/_/\1./'
...perhaps a more comprehensive example of the stream and manipulation required would be helpful?...or are we going for an obfusication award?
But this works:
echo 1_2_spell.xml | sed 's/_/\1./'
...perhaps a more comprehensive example of the stream and manipulation required would be helpful?...or are we going for an obfusication award?
..or even:
echo 1_2_spell.xml | sed 's/_/./'
as long as you don't stipulat the g (global obtion, only the first _ will be substituted!
echo 1_2_spell.xml | sed 's/_/./'
as long as you don't stipulat the g (global obtion, only the first _ will be substituted!
ASKER
How can I make a check in the characters between the "_" to be numeric?
For exp:
1_2_spell.xml convert 1.2_spell.xml
but for
1700_command_spell.xml (ignore: dun convert as "command" is non numeric)
Thanks.
For exp:
1_2_spell.xml convert 1.2_spell.xml
but for
1700_command_spell.xml (ignore: dun convert as "command" is non numeric)
Thanks.
check for numeric as
[0-9]+
[0-9]+
echo 12.34_Abc.xml
echo 12.34_Abc.xml | sed -e 's/\([0-9]\+\)\.\([0-9]\+\ )_\([^0-9] \+\)\.xml/ \1_\2.\3.x ml/'
echo 12.34_Abc.xml | sed -e 's/\([0-9]\+\)\.\([0-9]\+\
ASKER
It gives :
12_34.Abc.xml
I need:
12.34_Abc.xml
Please advise.
Thanks.
CM
12_34.Abc.xml
I need:
12.34_Abc.xml
Please advise.
Thanks.
CM
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would have thought that my solution and that of avizit also did what was required. The check for numbers was an additional insight.
Anyway - your call:)
Anyway - your call:)
seems to work