Reputation: 87
I am new with shell script programming and I want to create a searching program using shell script. When user enter the modified time, it will show a list of all files which have modified time less than the user's input. But nothing appear. What have I messed up?
#!/bin/bash
echo "Enter a date:"
read -r numdate
result4=$(find -type f -mtime -"$numdate" -print)
echo "$result4"
Upvotes: 0
Views: 192
Reputation: 21965
Below will work
#!/bin/bash
read -p "Enter day/s : " numdays
echo "Files which were modified $numdays days ago"
result4=$(find -type f -mtime "$numdays")
echo "$result4"
Notes:
-p
option. find manpage says the mtime
expects days as an integer:
-mtime n
File's data was last modified n*24 hours ago.
Upvotes: 1