2
I wish someone could help me to create this script correctly, in this case it is to create a script that Oce type the name and directory of a file and then indicate whether it was located or not and that manages this type of output on the screen
- $ ./locates.sh
- Type the file name: .txt file
- Enter the directory name: /home/user/Documents
- The.txt file was not located in the directory /home/usuario/Documents
Or
- $ ./locates.sh
- Type the file name: .txt file
- Enter the directory name: /home/user/Codes
- The.txt file was located in the /home/user/Codes directory
I did it but it wasn’t totally right
#!/bin/bash
# localiza.sh
# script para localizar arquivos e diretórios
echo "Digite o nome do diretório: "
read DIR
echo "Digite o nome do arquivo: "
read ARQUIVO
#
find $DIR -name '$ARQUIVO' && echo "Busca efetuada com sucesso!" || echo "Arquivo não encontrado"
What happened? Any errors?
– Marcelo de Andrade
Even if you don’t find the file but find the directory the message is always the same.
– Fumero
Always appears the search message successfully performed even if the file does not exist.
– Fumero