Tagged Questions
7
votes
4answers
5k 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 ...
6
votes
1answer
317 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 | ...
3
votes
1answer
866 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
193 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
4answers
1k 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 ...
2
votes
2answers
77 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 ...
2
votes
2answers
361 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 ...
0
votes
1answer
424 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 ...
-1
votes
1answer
185 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:
...