Hi
I have command and i want to short it.
tr -c '[:print:][:cntrl:]' '[-*]' | sed 's/---/-/g'
I want one sed command it is possible to include tr command in to sed
Thanks
Hi
I have command and i want to short it.
tr -c '[:print:][:cntrl:]' '[-*]' | sed 's/---/-/g'
I want one sed command it is possible to include tr command in to sed
Thanks
You got to pipe it if you want tr command.
You cannot "include" the tr command into the sed programme, but you can emulate it. I think this is what you intended:
sed -E 's/[^[:print:][:cntrl:]]/-/g; s/-+/-/g ' input-file >output-file
That will work with a BSD style sed. For Gnu, replace -E
with -r
.
It replaces anything that isn't a printable character, or a control character, with a single dash. Any consecutive dashes are then replaced with a single dash.
same output// do have any other code.
It would help to see a sample of your input, especially since printable characters and control characters cover pretty much everything that might be in the input. It would also help to know what you are attempting to accomplish.
Hi Guys,
I wand find and replace all Extended ASCII Codes from all my log files.
My Log files:
Code:
/home/Kalr/PPool/Output
i have logs file in sub dir.
/home/Kalr/PPool/Output/X
/home/Kalr/PPool/Output/Y
/home/Kalr/PPool/Output/Z
My Abc.log file input:
Extended ASCII Codes :-
l-
i want to replace with -
l-
Is there any possibility to change all Extended ASCII Codes from all log files.
Interesting. I just created a test file with all characters 128 - 255 (8 bit on) and the above sed removes them as expected.
What OS and what version of sed?
My sample input with plain text scattered about:
���this is a test
�...�����and another test
����'���--����
foo bar���
other stuff here: �������������������������������������������������������������������������������������������
After running the above sed:
-this is a test
-and another test
-
foo bar-
other stuff here: -
Maybe someone else has a suggestion, but it works as I would expect with both a Gnu and BSD sed.
Regular sed:
sed 's/[^[:print:][:cntrl:]]/-/g; s/--*/-/g ' infile
or
sed 's/[^[:print:][:cntrl:]]\{1,\}/-/g' infile
BSD/GNU:
sed -E 's/[^[:print:][:cntrl:]]+/-/g' infile
Try:
LANG=C sed 's/[^[:print:][:cntrl:]]\{1,\}/-/g' infile
S.
--
(Do you know the strings command by the way? strings infile
)
Thanks a lot ....you guys same my lot of time and effort