Need to see file extensions in Terminal

Discussion in 'all things UNIX' started by Riverrun, Jan 29, 2010.

Thread Status:
Not open for further replies.
  1. Riverrun

    Riverrun Registered Member

    Joined:
    Feb 19, 2007
    Posts:
    376
    Location:
    ~
    Someone I know needs to delete a couple of files that are causing problems on a Mac and couldn't locate them so he asked me. The old Linux skills came in handy and I was able to locate the files straight away by cding to them in Terminal.

    I would like to see the extension of one of the files in particular but it's not visable.

    Unfortunately, my Terminal skills are still fairly limited (I'm learning) and not being a native geek, I still can't make head nor tail of the instructions in 'Man.'

    The upshot is that I would like to see the extension of the file that needs deleting just to be sure, and I don't know how to craft the command.

    Mac forum users are generally accustomed to doing things in the GUI and terminal operations are often foreign to them so it's not much use to ask in the Mac forums.

    So, what I need to know is, how would you shape an "ls" command that will also reveal the file extentions?

    Many thanks folks.
     
  2. dan_maran

    dan_maran Registered Member

    Joined:
    Aug 30, 2004
    Posts:
    1,053
    Location:
    98031
    Normal ls will show you the file extension of unhidden files
    ex:
    Code:
    Me@Ubuntu:~/Downloads$ ls
    79955.pdf  ghost32.zip    LinuxMint-8.iso
    79960.pdf  heic0710a.tif  Setup_QuickBooksPro2010.exe
    ls -al will show you the information on all the files in the directory, even hidden ones in a list format (-l)
    Code:
    Me@Ubuntu:~/Downloads$ ls -la
    total 729764
    drwxr-xr-x  2 Me Me      4096 2010-01-29 08:39 .
    drwxr-xr-x 50 Me Me      4096 2010-01-28 10:43 ..
    -rw-r--r--  1 Me Me   1024256 2009-12-28 10:16 79955.pdf
    -rw-r--r--  1 Me Me    733736 2009-12-28 10:13 79960.pdf
    -rw-r--r--  1 Me Me   1434009 2010-01-06 10:32 ghost32.zip
    -rw-r--r--  1 Me Me  21945904 2010-01-13 10:49 heic0710a.tif
    -rw-r--r--  1 Me Me         0 2010-01-29 08:39 .hidden.txt
    -rw-r--r--  1Me Me 721573888 2010-01-27 13:23 LinuxMint-8.iso
    -rw-r--r--  1Me Me    536832 2010-01-13 14:36 Setup_QuickBooksPro2010.exe
    
    HTH

    Dan
     
  3. Mrkvonic

    Mrkvonic Linux Systems Expert

    Joined:
    May 9, 2005
    Posts:
    10,223
    You can also use "file" to determine the true file type.
    Mrk
     
  4. Ocky

    Ocky Registered Member

    Joined:
    May 6, 2006
    Posts:
    2,713
    Location:
    George, S.Africa
    Like so:-

    ~/Videos$ file -b Dvorak9-Karajan
    RIFF (little-endian) data, AVI, 640 x 464, 25.00 fps, video: DivX 5, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
    ~/Videos$
     
  5. Riverrun

    Riverrun Registered Member

    Joined:
    Feb 19, 2007
    Posts:
    376
    Location:
    ~
    Guys, thanks a lot. Did the trick and no damage done; the Mac is fine.

    Mind you, if I'd looked a little closer and did a bit more digging myself, I needn't have bothered the good people here. Mr K has the following very useful link: http://www.linuxcommand.org/, listed in the 'Linux ... Where to start? Recommended reading' thread.

    This confirms for me once again how useful the bash shell is. I envy those of you who are advanced, the whole world of Unix from Solaris to Mac to BSD is open to you. For myself, I'm thankful for such modest skills as I've managed to acquire and I'm patiently learning a little more each day and that's all because I took the decision to move to Linux almost 3 years ago now and I have never regretted doing so.

    Cheers again, folks.
     
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.