Tagged Questions
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 ...
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
...
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 ...
3
votes
2answers
174 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 ...
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) ...
-1
votes
1answer
172 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:
...
1
vote
2answers
110 views
Grep a string from file
I have 5 filenames created inside a folder for one operation.The filenames are in the following format.
ES_currentdate_currenttime_processid_uniqueid.log
I want to read the status from the latest ...
2
votes
3answers
204 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 "#" ...
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
...
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
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
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 ...
2
votes
2answers
650 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 ...
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 ...