1
vote
2answers
73 views

List all the html tags in a file

I want to know if there is a way to list all the html tags in a file. Lets say I have a file file.html <html> <head> <title>Test</title> </head> <body> This is a ...
0
votes
2answers
153 views

Solution to integer expression expected [closed]

So I when I run this code on my mac there are no errors, and it provides me the perfect output. But when I run it on Ubuntu or CentOS i get the following error integer expression expected ...
1
vote
1answer
59 views

Why does the same sed regex (after grep) fail when run in a bash script vs bash command line?

Here's the script. It is successful when I run it from the BASH prompt, but not in the script. Any ideas? When I say "fails," I mean the sed regex doesn't match anything, so there is no replaced ...
0
votes
2answers
67 views

How to count number of instance of a word starting at another word

I need to grep the MySQL-error log starting at today's date formatted like: `date +"%y%m%d"` (140710) And look for all instances of the word partitioned. I've tried various things to no avail. ...
2
votes
4answers
260 views

Inserting a line in a file only if this line isn't yet part the file

Total newbie to shell scripting, I am searching to create a script to automatically apply some custom configuration to text based configuration files. In the present case, I am searching to add 2 ...
1
vote
5answers
52 views

grep for text that may or may not be present

Lets say I have a file batman; robin; superman; password = ""; wonderwoman green lantern if I want to check if there is a password present, i.e there is something entered in the "" . here is an ...
0
votes
1answer
170 views

How to execute grep in tcl for getting XYZ-123 type pattern

How can I execute this grep command in TCL? grep '[A-Z][A-Z][A-Z]\-[0-9][0-9][0-9]' file1 > file2
2
votes
3answers
129 views

grep on a Java Method

Lets say I have a java class called DirectAction some of the methods in the class have the word "action" or "Action" What is the grep command to get the names of all the methods who have "Action" or ...
6
votes
2answers
518 views

What's the most efficient way to grep for two completely separate things and assign the values to separate variables?

CentOS 6.x I want to take the output from curl, grep for two completely separate strings, and assign their respective values as variables. What is the most efficient way to do this (without writing ...
0
votes
2answers
272 views

Using grep to find first two numbers of IP addresses?

I'm trying to figure out how to use grep to pull out only the first two numbers of an IP address in a list. I've got a routine that is isolating the log entires (from Exim) that I need, now I just ...
0
votes
1answer
58 views

Need to grep for specific lines from ongoing log and save it in some file

So, let me start with the overall outcome that i want to achieve. There is just one log, which will have info on certain devices, that i am upgrading. I use "tailf log" to monitor the log. Now, ...
4
votes
4answers
3k views

How can I suppress output from grep, so that it only returns the exit status?

I have the grep command. I'm searching for a keyword from a file, but I don't want to display the match. I just want to know the exit status of the grep.
-1
votes
1answer
722 views

if condition, loop in grep [closed]

Could someone please provide help for me. I tried to start writing a shell script but am getting hung up with this issue. I need to grep commands "adb shell ps" and find in it 3 processes with names: ...
2
votes
2answers
425 views

Add a suffix string to end of each line? [duplicate]

I have two files: file01: line1 line2 line3 file02: A B C And I want to get line1 A line2 B line3 C I could possibly write a Perl script but it is better if I don't need to. I have tried ...
2
votes
2answers
482 views

Parse apache logs to exclude IP ranges

I need to look for some requests in a huge pile of apache logs. My only requirement is this: I need to only view the requests coming from any IP address that is NOT included in a list of 50 IP ranges ...
6
votes
1answer
555 views

Peculiar piping grep/head behavior

I'm helping the netadmin here with a perl regex to automate operating on some snapshots from our SAN and our scripts does stuff like this: varinit1=$(iscsiadm -m session | grep rbmsdata1 | head -n1 | ...
4
votes
4answers
2k views

cut / grep and df -h

How can I grep or cut the "173G" under "Verf"? I need this for Unix scripting in school. jonas@jonaspc:~/$ df -h /dev/sda2 Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf /dev/sda2 ...
0
votes
1answer
634 views

grep searchstring /etc/crontab strange behavior in BASH script

I am working on a BASH script which creates automated backups via the crontab. I am trying to use myVARIABLE=`grep backup /etc/crontab` to return lines containing "backup" if an entry has already ...
3
votes
1answer
1k views

How to use a value returned by a script in grep filter?

I'm on FreeBSD's csh. I want to form a row with domains of one user and then use this row to filter exim maillog to get only mail from/to this user's domains. I wrote a script to form a row from a ...
2
votes
2answers
84 views

How do I execute a command on a given string in each line of a file?

Let's assume that I already have a file created. This file creation comes from the execution of a command. The contents of the file will be up to 4 different lines looking something like this: LUN ...
8
votes
4answers
8k views

grep — removing text after delimiter token

I have a file in which I need to eliminate everything after the first ; on every line. So a file like this: sdfsdsdf; fsdfsddf;sdfsd; Will result in this: sdfsdsdf fsdfsddf I have looked into ...