lnotik
lnotik

Reputation: 115

find: Arguments to -type should contain only one letter

#!/bin/bash 


echo "please enter a path where to search:"
read myPath

touch --date "2012-01-01" /tmp/start
touch --date "2012-01-01" /tmp/end

until  [ "$myPath" = $(pwd) ] 
do
echo "please enter a correct path where to search:"
read myPath
done


RESULT= "$(find  $HOME "-type -f" -newer /tmp/start -not -newer tmp/end)"

echo $RESULT

When I'm trying to execute it I'm getting:

find: Arguments to -type should contain only one letter
TimeStamp: line 17: : command not found

Upvotes: 2

Views: 1621

Answers (3)

David W.
David W.

Reputation: 107040

You have:

RESULT= "$(find  $HOME "-type -f" -newer /tmp/start -not -newer tmp/end)"

find: Arguments to -type should contain only one letter

Several things: Remove the quotes around -type -f. I'm not sure why you put them there. The correct argument for the -type parameter should be f and not -f.

TimeStamp: line 17: : command not found

You did a touch on /tmp/end, but you're looking at tmp/end. This is saying the same thing as $PWD/tmp/end. You need a slash at the front to anchor this to the root of the directory structure. You need /tmp/end and not tmp/end.

Try:

RESULT= "$(find "$HOME" -type f -newer /tmp/start -not -newer /tmp/end)"

Upvotes: 1

Bela Vizer
Bela Vizer

Reputation: 2537

I would try this:

"$(find $HOME -type f -newer /tmp/start -not -newer tmp/end)"

Upvotes: 1

Bohemian
Bohemian

Reputation: 425073

For starters, why do you have -type -f outside the quotes? And it's -type f not -type -f (no dash before the f)

Try this:

"$(find $HOME -type f -newer /tmp/start -not -newer tmp/end)"

Upvotes: 2

Related Questions