The reason, why this fails (and why Scrutinizers solution works) is subtle: by declaring the variable "var_find" with some content you make this content one string, even if this string contains several blanks, which usually separate strings in the shell.
Lines are read in fields separated by so-called "field separators" (white space, semicolon, etc.) by the shell. But in quoted strings these field separators are ignored. The following script will show that:
call the script with ./script a b c and it will print the expected value 3. Issue ./script a "b c" and it will print only 2, because "b c" is considered to be one string.
To come back to your find-command: find knows how to handle the "-name"-option and the "-name"-option knows that it expects exactly one argument: a filename mask. But find doesn't know about a "\( -name "*.xml" -o -name "*.jsp" \)"-option and this is what it complains about.
Hi,
How can I use find command to search string/pattern in a file recursively?
What I tried:
find . -type f -exec cat {} | grep "make" \;
Output:
grep: find: ;: No such file or directory
missing argument to `-exec'
And this:
find . -type f -exec cat {} \; -exec grep "make" {} \;... (12 Replies)
I have a sample file with following output:
HTTP/1.1 200 OK
User: admin
Set-Cookie: AMBARISESSIONID=y3v3648yqcno32nq478kw7ar;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 6057
Server:... (4 Replies)
Hi All,
I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd.
What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
I have a script in tcsh and I want to have a find option to which I can pass a file search pattern I want using the command:
/home/chrisd/tatsh/trunk/hstmy/bin/tcsh/raytrac.tcsh -f=*rc*
The set command seems to fail when user does not supply a search pattern (if user just supplies -f, a... (2 Replies)
Hi,
I would like to use find to search for multiple types. For example search for symlink and regular file but not directories, sockets etc.... Something like:
find . -type l,f -name "stuff"
But of course it does not work.
Is there any way to avoid an if statement and to do it faster?
... (0 Replies)
Hello All,
I have a file which is having below type of data,
Jul 19 2011 | 123456
Jul 19 2011 | 123456
Jul 20 2011 | 123456
Jul 20 2011 | 123456
Here I wanted to grep for date pattern as below, so that it should only grep "Jul 20" OR "Jul ... (9 Replies)
There are these ksh files and config files that are written and updated on a daily basis.
All I want to do is write a script that finds both these types of files and archive them on a daily basis, to help in restoring in times of system outages and so on. Particulary I'm interested in .ksh ,... (9 Replies)