I'm watching a particular expression as it is appended in a line to a file:
So whatever value I pass into this script will tail -f the file, but only show me lines that contain the value:
However some of the output contains a #20 control character (or translation of a control character - whatever). I want it removed from the output. I tried a few variations with the scipt:
I can't seem to get these #20's removed. Can anyone suggest?
I just realized something. If $@ is ever more than one parameter, it will split into individual arguments in your sed statement, even inside double-quotes! That is $@'s function, to split on arguments and nowhere else... Try "$*" inside double quotes instead.
Thanks for your continued support. I did try using an asterisk instead but I'm still not getting the desired result. I'm really confused on how to add the secondary sed statement without wrecking this whole thing. As you see before I've googled various ways to combine sed statements but it doesn't seem to be working as it should.
These attempts do not remove the #20's:
I tried outputting results to a text file and then using the following sed and it worked:
Granted instead I'm replacing the #20's with spaces but it still works. So I believe my sed statement is correct, but it seems I'm not appending it correctly. Can anyone advise how it should be added onto my tail command?
** Update **
I can search just for the expression I'm looking for - which gets passed into $@ or $* (tried both) so it appears that the issue is piping a sed statement for removing the #20's is the problem. Sed using -n '/$@/p' isn't a problem, but damnit if I put sed 's/#20/ /g' on the end that just kills any output. I've tried putting \#20 as well as including it in double quotes. What is the problem with my sed statement?
*** update ***
I moved the sed statement to the beginning of my tail statement and somehow this works. I guess it pulls all the #20's from everything before it does the tail...not really sure why I have to do this and piping the sed statement at the end kills it.
I am learning SED and just following the shell scripting book, i have trouble understanding the grep and sed statement,
Question : 1
__________
/opt/oracle/work/antony>cat teledir.txt
jai sharma 25853670
chanchal singhvi 9831545629
anil aggarwal 9830263298
shyam saksena 23217847
lalit... (7 Replies)
Hello!
I know that this expression gets rid of non-alphanumeric characters:
sed 's///g'
and I understand that it is replacing them with nothing - hence the '//'-, but I don't understand how it's doing it.
It seems it's finding strings that begin with alphanumeric and replacing them with... (2 Replies)
Hello All,
I have something like below
LDC100/rel/prod/libinactrl.a
LAA2000/rel/prod/libinactrl.a
I want to remove till first forward slash that is outputshould be as below
rel/prod/libinactrl.a
rel/prod/libinactrl.a
How can I do that ??? (8 Replies)
sed -e '1d' -e 's/^\(]\{2\}\)-\(]\{3\}\)-\(]\{4\}\).*/"0000020\1\200\3"\,/g' abc.txt
This script returns many duplicates due to the duplciates in the .txt file.
i.e.
...
"000002012149000060",
"000002012149000064",
"000002012149000064",
"000002012149000064",
"000002012149000064",... (9 Replies)
I had a string in perl script as below.
Tue Augáá7 03:54:12 2012
Now I need to replace the special character with space.
After removing the special chaacters
Tue Aug 7 03:54:12 2012
Could anyone please help me here for writing the regular expression?
Thanks in advance..
Regards,
GS (1 Reply)
Hello All,
I'm trying to extract the lines between two consecutive elements of an array from a file.
My array looks like:
problem_arr=(PRS111 PRS213 PRS234)
j=0
while } ]
do
k=`expr $j + 1`
sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt
---some operation goes... (11 Replies)
I need a perl substitution to remove only the comment in the line . That line may have '#' with in double quotes .I used the following ,
s/(^.*\".+?#.+?\".+?)(#.*)/$1/g
It works for ,
print " not a comment # not a comment " . "not a comment # not a comment" ; # It is a comment
... (3 Replies)
Hi dears,
The script should watch for a file in particular directory. If the file not come into the directory even after 30 seconds from execution of the script, then script should exit saying “file not arrived”
Any help ?? (4 Replies)
I have been trying to remove some improperly formatted lines of output from fortran code I have been using. The problem is that I have some singularities in the math for some points that causes an incorrectly large value to be reported that exceeds the normal formating set in the code resulting in... (2 Replies)