Programming :: Remove Characters From Grep Output?

Apr 14, 2010

How can I remove characters from grep output using sed? code...

View 9 Replies


ADVERTISEMENT

Programming :: How To Get Grep Output 0 - 1 And Test It

Apr 7, 2009

I am trying to use a shell script to find a string in a file and do something when found. code...

What should happen is pppd will start in a different process and stream it's output to pppdout. pppdout should be created in the current folder. Then the script should periodically check the pppdout file for the string Script (which eventually will appear, some seconds later) and when found exit the script. Ultimately the script will do something useful when the text is found. However, the output from the program is a repeating: 'scriptname.sh: 12: FOUND: not found'

Where scriptname.sh would be the name of your script and 12 refers to the line with 'done'.

Why does grep not find the text, or at least why deos my script not check the grep output correctly?

View 10 Replies View Related

Programming :: Omit Specified Characters From The Output Of A Command?

Nov 18, 2010

After typing "man cut" in my terminal I can't seem to find this answer.

I am trying to write several shell scripts and want to remove the 'lp:<package name>' from the beginning of each line of the output of "bzr ls" as well as any notices at the beginning of the output, leaving only file and folder paths.

View 6 Replies View Related

Programming :: Remove Characters From Within Variable

Feb 20, 2011

I am doing a mysql query with a bash shell script like:
mysql translator -u root --password=******** -e "SELECT word FROM tagalog ORDER BY RAND() LIMIT 1" | while read line; do
echo $line

So when I echo the value of $line I get:
word
magandang umaga
"word" is the name of the row in the table and maganda umaga is a randomly selected choice from the row. Is there a way i can remove the name of the row from the variable $line. With a result that will allow me to echo $line and output only the randomly selected entry in from the row e.g. magandang umaga

View 13 Replies View Related

Programming :: Using Sed To Remove All But The Last 17 Characters On A Line?

Jun 3, 2010

I'm having a bit of a headbanger trying to work this one out. I'm trying to remove all of the characters on a line apart from the last 17. For example, I need to change this:

Code:

00000000000000000089;0bbfaeb8
01000000000000000089;0bcb5948
00000000000000000089;0bcc4c40

[code]....

View 5 Replies View Related

Programming :: Remove Script Data From File Using Grep & Sed?

Jul 13, 2010

On one of my servers, it appears that a bunch of html files got the following code added to it...Quote:[URL]I was going to try to remove this line using grep & sed... as sample
grep -lr -e 'apples' *.html | xargs sed -i 's/apples/oranges/g'I can get the grep portion to work...

Code:
grep "<script src='http://b.rtbn2.cn/E/J.JS'[>][<]/script[>]" *
But not the sed

View 1 Replies View Related

Programming :: Remove All Lines Containing Extended Characters

Nov 7, 2010

I am using 'sed -e /foo/d' to match lines which I want to delete from a file. I discovered I have some lines which contain random (extended?) characters like 'ủ' which I would also like to delete. The lines in the file should only contain alpha numeric characters.

View 8 Replies View Related

Programming :: Remove Special Characters From String

Jan 30, 2011

I am reading strings from a file using readline() function,the file contains some strings which has only special characters, I need to avoid the strings which has only special characters, the special characters are not similar. How to do it in python.??

View 2 Replies View Related

Programming :: Remove Odd Characters From CSV Files Using A Script?

Apr 27, 2010

I hope you can help. I have a collection of spreadsheets with data that needs to be imported in to SQL. The data has been manually entered although there are portions where data has been copied and pasted from the web.

When converting these sheets to a CSV I get strange characters where it looks as though data has been copied and pasted. Is it possible to write a script (AWK?) to pull out these characters?

I guess the script will need to keep alpha characters, spaces, numerics and commas but nothing else. How easy is this to do?

View 7 Replies View Related

Programming :: Storing Grep Output To Feed Awk To Retrieve Entire Records Matching Variable

Jul 28, 2010

I have two files :

FileA
prot1
prot5
prot9
prot15

[Code]....

What I need to do is to extract from fileB the fields containing only the strings in fileA.

I thought awk could do the job easily with :

Code:
awk 'BEGIN { RS = "###" } /'$variable'/' fileB > output

where variable would maybe be the output of grep from fileA. So can I store the output of grep in a variable to use it afterwards with awk ?

something like that:

Code:
result=`grep prot. fileA` ; awk 'BEGIN { RS = "###" } /'$result'/' fileB > output
but that doesn't work. I'm always getting the entire fileB.

The output of grep get stored in the variable, I verified that with echo. So there is something that I just don't get... It seems to me that the above line should work.

View 11 Replies View Related

Programming :: Remove All Alphabetic Characters At Beginning Of String

Jul 26, 2010

I am working with a Tcl script and have some strings in the following format (RE):
[a-zA-Z]+[0-9]{6}-[0-9]

There are some leading letters, combinations of capital and lowercase. Then six digits, followed by a hyphen, then one more digit. I would like to remove all of the leading alphabetic characters from the string. The resulting string would then be in this format: [0-9]{6}-[0-9]. In other words, six numeric digits, a hyphen, then one more digit.

I have tried:
Code:
set newstr [string trimleft $origstr alpha]
But that only removes the first alphabetic character, not all of them.

I couldn't get anything with regsub to work correctly, but I am somewhat of a noob with RE's in general and regsub in particular. There are usually 5 leading letters at the beginning of these strings, and I could in most cases get away with using string replace and constant indices to extract the substring. However, my preference is for this to be robust enough to handle all cases with 1 through n leading alphabetic characters.

View 3 Replies View Related

Programming :: Variable String File Base - Output File Doest Not Exclude The Values In Grep -av

May 1, 2011

My script.

This is may script:

Code:

Problem: Output file doest not exclude the values in grep -av

View 3 Replies View Related

General :: GREP - Search Special Characters

Feb 10, 2010

I need to search for the following pattern with GREP in a text file:

So I tried already:

But none of those works...I think probably because GREP doens't like the special character > in the middle of the serach pattern.

At the end I just need to now if GREP found the pattern in the file or not, so it should give me a 0 or a 1 back, once I check the value of the variable "?" after using the grep command.

View 4 Replies View Related

General :: Grep Not Recognizing All The Meta-characters When Used With -e Option.

Oct 13, 2010

I was trying to use the grep command with -e option to test some regular expressions with it but to surprise not all the meta characters were being recognized by the grep engine, how ever egrep works perfectly fine.

For example : The following egrp command works fine:

View 3 Replies View Related

Programming :: Input File - Grep Within Grep

Nov 22, 2010

I need to kind of grep within grep. My input file would be something like:

[Code]....

and I need to find the first occurrence of hello before MY PATTERN (hello 9008 in this case), so the output should be:

[Code]....

View 4 Replies View Related

General :: Bash - Using Find Or Grep To Locate Filenames With Accented Characters From A Different Encoding System (Windows)

Dec 6, 2010

I tried to tag late onto a question similar to mine on stackoverflow (Find Non-UTF8 Filenames on Linux File System) to elicit further replies, with no luck so far, so here goes again... I have the same problem as the OP in the link above and convmv is a great tool to fix one's own filesystem. My question is therefore academic, but I find it unsatisfactory (in fact I can't believe) that 'find' is not able to find non standard ascii characters.

Is there anyone out there that would know what combination of options to use to find filenames that contain non standard characters on what seems to be a unicode FS, in my case the characters seem to be 8bits extended ascii rather than unicode, the files come from a Windows machine (iso-8859-1) and I regularly need to fetch them. I'd love to see how find and/or grep can do the same as convmv.

[Code]....

View 2 Replies View Related

General :: Grep - Output Show Only Right Of?

May 17, 2010

I forgot a lot of my command line. I am doing cat file | grep "error" and i would like it to show everything to the right of G:/ including G:/ if possible. I figure its an awk command but i dont know what. I tried awk '{print $8+}' but + does not work like i hoped and guessed.

View 2 Replies View Related

General :: Grep IPs From Ifconfig Output?

Mar 6, 2011

Following is my ifconfig output code...

I want to do some thing grep that I see the IP corresponding to each LAN card?
Is that possible?

View 8 Replies View Related

General :: Exec Command With Grep Output?

Feb 15, 2011

I have a requirement to find the files having its name as ack_reply. However, there are many other files in the same directory as these resides. Now I have to remove these files from the folder and retain others after 7 days. So I tried to write the below script with grep command.

find $directory -type f -mtime +7 | grep ack_reply

how can I pass this output to -exec command.

If I am not using grep command my script would be as

find $directory -type f -mtime +7 -exec remove.sh {}\;;

How can I use -exec with grep and find.

View 4 Replies View Related

General :: Grepping Grep Output Fails

Feb 5, 2010

I'm trying to grep the output of ngrep. Unfortunately when I add another grep to the pipeline, I get no output at all. It can be some other command too - cat / grep / tee - everything breaks the chain. Example:

[Code]....

If I use cat somefile instead of ngrep at the start, everything works as expected.

View 2 Replies View Related

General :: Grep - Filtering Output By OR Condition

Aug 13, 2010

Is there some way to filter output of command by OR condition in Linux? There is filtering by AND condition with grep in way like:
ls -l | grep "^a" | grep "z$"

That says: list all files that beggins with "a" AND ends with "z" (so there is shorter way to write this: grep "^a.*z$", but it is not matter). Is there some way to perform test by OR condition? For example: files that starts exactly with "xen" OR files that ends exactly with ".rpm". But exactly, not something like:
grep "[xen]{0,3}.*[.rpm]{0,4}"

View 2 Replies View Related

General :: Filtering UDS From Output Of Netstat Without Grep?

Aug 24, 2010

how I cat to filter out information about Unix Domain Sockets from netstat output without grep? Is there some option for command (I not found it in man of netstat).

View 2 Replies View Related

General :: Filter Out Unique Results From Grep Output?

Feb 21, 2010

In linux, I can grep a string from a file using grep mySearchString myFile.txt.
How can I only get the result which are unique?

View 1 Replies View Related

Ubuntu :: Output Of Command In Less And The Words Highlighted By Grep?

Sep 1, 2010

So theres this command

Code:
man -k mail
Which lists commands that contain the keyword "mail" in their description.I want the output of this command in less and the words highlighted by grep. Something like

Code:
man -k mail | grep mail | less
The command doesn't work, how do I fix it?

View 2 Replies View Related

General :: Can't Save Grep Output Into Variable / Solution For This?

Feb 3, 2010

I would like to grep two numbers out of a text file, and divide them.

Here is the script code...

It feels like grep saves a new line too? or what is happening? i simply can't divide them, as it handles the variables as they are empty (and prints the two numbers although they were not printed

View 6 Replies View Related

General :: Grep A String Like "ab?c12345678" Where 3rd Character Is Unknown While Other Characters Are Known?

May 7, 2011

How to grep a string like "ab?c12345678" where 3rd character is unknown, while other characters are known.

View 2 Replies View Related

Ubuntu :: Piping Command Output Into Grep As Search Term?

Nov 11, 2010

I want to pipe the output of a command into grep as the search TERM, rather than the text to be searched, like this for example

Code:

cat /var/log/auth.log | grep date "&b &d"

so that I only see the lines in auth.log for the current day...but obviously that line doesn't work.... is there a way to do this with grep, or even another command?

View 4 Replies View Related

Ubuntu Servers :: Using TShark And Grep - Output Empty File?

Jul 13, 2011

I am not sure why this does not work..
tshark |grep 'string'
Gives me what I want but
tshark |grep 'string' >/tmp/outputfile
Gives me an empty file.

View 3 Replies View Related

General :: Filtering Out Duplicate Lines From A Find/grep Output

Mar 22, 2010

I have some big files of logs that contain errors printed by an app. They are most of the time relevant, however most of them are similar. So i figured i could check what happened between a time interval with a find.

Im using this one

Code:

And I get an output similar to this one.

Code:

Is there a way to condensate the output lines to get only one or two, indicating the start and last occurrence of a block? Or I need to create a program to do so?

Because right now I get thousands of similar lines, but when I'm scrolling through them i sometimes miss relevant information that i would've otherwise noted if it wasn't all that spammy.

View 10 Replies View Related

Software :: Remove Particular Characters Using Sed

Dec 13, 2010

file = TT.ParlayX_RequestLog_78653_20101212180044.log.17490
1. Want to remove the characters before the first dot (.) including the dot (.)
2. Want to remove the characters after the last dot (.) including the dot (.)

That is, basically, I want the output as:
ParlayX_RequestLog_78653_20101212180044.log

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved