On Sun, Mar 25, 2012 at 11:39 PM, Mehul Ved <[email protected]> wrote:
> On Sun, Mar 25, 2012 at 10:02 PM, Bharath Kumar > <[email protected]> wrote: > > > #!/bin/bash > > echo -e "Input the file that you want to search: c" > > read input > > find ~ -name ${input} > > Use $"input" instead of ${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 > > Also, the inline commenting method is wrong. In bash, you use # for > commenting. > > > read input1 > > file ${input1}| cut -d: -f 2 > > > > > > Thanks, > > Bharathkumar A.V. > > _______________________________________________ > > ILUGC Mailing List: > > http://www.ae.iitm.ac.in/mailman/listinfo/ilugc > > > > -- > With Regards, > Mehul Ved > _______________________________________________ > ILUGC Mailing List: > http://www.ae.iitm.ac.in/mailman/listinfo/ilugc > Determining the file type using the extension is the *wrong*. This is what windows does - when an executable file has a folder like icon (in windows) people will try to open it thinking they have created it and the virus file executes - a trap. Anyway people struck up with Windows need to care for it. Why don't you use "file" command instead of finding the extension? The "file" command returns the MIME type of the file. If the file is an mp3 file it says "Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 160 kbps, 44.1 kHz, JntStereo". Similarly for other type of files. If by chance you rename the mp3 file with a .pdf extension or some thing else the "file" utility will provide the correct type. "file" utility reads magic header in the file to determine its type (not based on extension). You may need to use extension only when the file is of type "ASCII English text" - it may be a C or MATLAB program or any thing that is created with a text editor (since all C files are text files). Hope this helps. _______________________________________________ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
