I have most of what I need so far I'm just unsure of the grep command to get only directories or if there isn't one. For context, this is the original request:
This script should take a single command line argument which will be a path to a directory. (done) The script should make sure that the path is, in fact, a directory and that th...
I have this script:
#!/bin/bash
CLASSPATH="/blah/libs/*:/blah/more/libs"
CMD="java -cp $CLASSPATH MainClass"
ALREADY_RUNNING_PID=`ps -ef --no-headers | grep $CMD | grep -v grep | awk '{print $2}'`
if [ "$ALREADY_RUNNING_PID" ]; then
echo "Already running"
exit 1
fi
$CMD &
problem is it doesnt work due to the asterisk in th...
I'm trying to overcome a limitation on our file structure. I want to grep a whole series of files in a known location. If I do a standard grep from command line
(grep -i searchpattern known_dir/s*.sql)
I get the following error:
ksh: /usr/bin/grep: 0403-027 The parameter list is too long.
so I have a little for loop that looks l...
Is there a way to make grep output "words" from files that match the search expression?
If I want to find all the instances of, say, "th" in a number of files you do;
grep "th" *
but the output will be something like (bold is by me);
some-text-file : the cat sat on the mat
some-other-text-file : the quick brown fox
yet-another-text-f...
Tried
$ echo "$STRING" | egrep "(\*)"
and also
$ echo "$STRING" | egrep '(\*)'
and countless other variations. I just want to match a line that contains a literal asterisk anywhere in the line.
...
Using just grep and sed, how do I replace all occurrences of:
a.example.com
with
b.example.com
within a text file under the /home/user/ directory tree recursively finding and replacing all occurrences in all files in sub-directories as well.
...
FILE:
hello
world
foo
bar
How can when remove all the empty new lines in this FILE?
Output of command:
FILE:
hello
world
foo
bar
...
I've currently got:
ls -1 $(pwd)/*
Gives me all the files in a directory with absolute paths - but formats it with the directory at the start of each list of files.
Is there a way just to get a list of files in a directory recursively (absolute paths) - excluding the directory/sub-directories themselves?
...
I've got a list of directories that contain spaces.
I need to surround them with ' ' to ensure that my batch scripts will work.
How can one surround each new line with a ' and a ' (quotes).
e.g.
File1:
/home/user/some type of file with spaces
/home/user/another type of file with spaces
To
File2:
'/home/user/some type of file wit...
File1:
hello world
foo bar
a word with a space
I need to replace all white spaces which are two or more in length with a semi-colon(;).
Result:
File2:
hello;world
foo;bar
a;word with a space
...
Here is a command line script for a dictionary lookup using Wordnet:
#!/bin/bash
# Command line look up using Wordnet - command line dictionary
echo "Type in your word:"
read word
/usr/bin/curl -s -A 'Mozilla/4.0' 'http://wordnetweb.princeton.edu/perl/webwn?s='$word'&sub=Search+WordNet&o2=&o0=1&o7=&o5=&o1=1&am...
I've been trying to implement a bash script that reads from wordnet's online database and have been wondering if there is a way to remove a variety text files with one command.
Example FileDump:
**** Noun ****
(n)hello, hullo, hi, howdy, how-do-you-do (an expression of greeting) "every morning they exchanged polite hellos"
**** Verb **...
File1:
hello
- dictionary definitions:
hi
hello
hallo
greetings
salutations
no more hello for you
-
world
- dictionary definitions:
universe
everything
the globe
the biggest tree
planet
cess pool of organic life
-
I need to format this (for a huge list of words) into a term to definition format (one line per term). How can one achieve...
How could I use grep and ls in ftp client...
I mean if I want to find some specific file I could use,
ls -l | grep pattern
thanks.
jcyang.
...
I'm trying to grep multiple extensions within the current and all sub-folders.
grep -i -r -n 'hello' somepath/*.{php,html}
This is only grepping the current folder but not sub-folders.
What would be a good way of doing this?
...
I need to find the text 'ifeq ($(Param1)' using grep. I try to assign search result to make variable. The problem is that single quotes don't escape text in make so when I try:
GrepResult:= $(shell grep 'ifeq ($$(Param1)' TextFile)
I get:
Makefile:214: *** unterminated call to function `shell': missing `)'. Stop.
The $ can be esca...
I want to use grep with two variables in a shell script
var = match
cat list.txt | while read word_from_list; do
grep "$word_from_list" "$var" >> words_found.txt
done
But grep expects to get a file as second input:
grep: match: No such file or directory
How can this be solved?
...
I'm trying to find where two variables are being concatenated in a directory of scripts, but when I try the following:
grep -lire "$DATA_PATH . $AWARDS_YEAR" *
I get "undefined variable" errors...
I thought I could escape the $s by using:
grep -lire "\$DATA_PATH . \$AWARDS_YEAR" *
But I get the same error - so, how do you grep for...
To prefix unique words with "UNIQUE:" inside a file I've tried to use a perl regex command like:
perl -e 'undef $/;while($_=<>){s/^(((?!\b\3\b).)*)\b(\w+)\b(((?!\b\3\b).)*)$/\1UNIQUE:\3\4/gs;print $_;}' demo
On a demo file containing:
watermelon banana
apple pear pineapple orange mango
strawberry cherry
kiwi pineapple lemon cranberry...
Some commands like svn log, for example will only take one input from the command line, so I can't say grep 'pattern' | svn log. It will only return the information for the first file, so I need to execute svn log against each one independently.
I can do this with find using it's exec option: find -name '*.jsp' -exec svn log {} \;. Ho...