Tagged Questions
6
votes
3answers
77 views
generate links of pages with incrementing variable
consider the links
http://unix.stackexchange.com/questions/tagged/linux?page=2&sort=newest&pagesize=15
...
4
votes
4answers
348 views
Count lines matching pattern and matching previous line
I want to count the number of times that a role is successfully deleted. The problem is that one line of the log file will show that the script is about to delete the role:
Prepare to remove role X
...
3
votes
3answers
2k views
How to search and replace text in all php-files in a directory and it's subdirectories
I am looking for a shell script that recursively traverses all .php files in a directory and performs a search & replace of a particular text pattern.
The search pattern is quite long ( > 5000 ...
3
votes
1answer
5k views
Filtering on dates with grep and awk
I have created the alias below in my .bash_aliases file
alias auth="grep \"$(date|awk '{print $2,$3}')\" /var/log/auth.log |
grep -E '(BREAK-IN|Invalid user|Failed|refused|su|Illegal)'"
...
3
votes
2answers
173 views
Optimizing a shell script with long running while loop
I have written a shell script which has to do the following:
Capture session commands into one file.
Every individual command into separate file.
Mail every individual command file content based on ...
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
3answers
2k views
solaris 10 + display 2 lines after match by grep?
I want to match for example:
The string e1000g0 from the lltconfig -a list , and then to display the two lines after the string e1000g0
so I get only the lines:
Node 0 du1a : ...
2
votes
2answers
649 views
How can I retain the console input in mplayer when reading from stdin?
I'm playing around with the command line interface of mplayer. I'd like to script it in the following way
find /some/path/ -type f | grep -vif blacklist | mplayer -shuffle -playlist -
where ...
2
votes
3answers
124 views
How to grep the last number on a line in a bash script
I have output from the smartctl -a command; one of the lines looks like this:
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 301
I've placed this into a variable (if that's the correct term) ...
2
votes
3answers
201 views
Very strange behavior with grep and IFS
I'm having trouble using grep, the returned results are "n-empty", I mean without the 'n' character...
This is the script sample :
OLDIFS=$IFS
IFS="\\n"
i=$(grep -ril $1 *)
echo $i
IFS=$OLDIFS
...
2
votes
2answers
164 views
add “#” in begining to selected lines in File
Requirement : ADD someting (i.e #) in begining of every line in file A which is grep from file B
File A
abcd
abdc
sdfg
asdfa
jon
ram
File B
jon
abcd
grep file B from file A and add "#" ...
2
votes
2answers
52 views
selecting specific string in a field
I have this file:
N104 F1810
N104 F3810
N104 F810
N104 F305
and a script to grep an input.
Script:
enter input
read input
cat file | grep $input
when I input “810”, I get the ...
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 ...
2
votes
1answer
188 views
Is it a good idea to supplement shell script with perl purely for use of regex?
I'm looking for a simple way to utilize regex in a UNIX shell script where not every system will have perl extensions built into grep. What is really helpful about perl regex here is back/forward ...
1
vote
2answers
42 views
mv complains about standard input in a pipeline that filters file name with grep
I'm trying to move several .avi files that have spaces in from a CD to my home folder. I've already know how to get rid of the spaces:
find /media/mathscd/ | grep -L -r "*.avi" | for file in *; do ...