[Ilugc] shell script to search for a file

  • From: bharath79in@xxxxxxxxxxxxxx (Bharath Kumar)
  • Date: 25 Mar 2012 16:32:56 -0000

Hi ILUGC members,

I have written a shell script to find out what type of file is the file I am 
searching for. If the resultant file name doesnt have any gap (like 
/path/name/Bharath_file.txt) I get the result correctly. But if the file has a 
gap (like /path/name/Bharath Kumar Letter.pdf) I get simply "ERROR". Is there 
any bug ?? Please help me resolve the bug please ??

This is my code snippet : 

#!/bin/bash
echo -e "Input the file that you want to search: c"
read input 
find ~ -name ${input}
echo -e "Input the file that you want: c" // Comments : I will copy the file 
with the full name that I want
                                           //to find out what type of file it 
is 
read input1
file ${input1}| cut -d: -f 2


Thanks,
Bharathkumar A.V. 

Other related posts: