1 / 5

OCCC CS2183-001 – Linux – Fall ‘07

OCCC CS2183-001 – Linux – Fall ‘07. Find Command and Links. by Gary Miller September 4, 2007 http://cs2183.garycmiller.com/. Find Cmd Examples. find . –print List out all files under the current directory find . -type f -ctime +10 -exec mv {} /tmp ; Move and files older than 10 days

Download Presentation

OCCC CS2183-001 – Linux – Fall ‘07

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OCCC CS2183-001 – Linux – Fall ‘07 Find Command and Links by Gary Miller September 4, 2007 http://cs2183.garycmiller.com/

  2. Find Cmd Examples find . –print List out all files under the current directory find . -type f -ctime +10 -exec mv {} /tmp \; Move and files older than 10 days find . -type f -ctime -10 -exec ls –lia {} \; 2>/dev/null List any files newer than 10 days

  3. Soft and Hard Links Soft links Pointers to programs, files, or directories located elsewhere (just like Windows shortcuts) If the original program, file, or directory is renamed, moved, or deleted, the soft link is broken.  If you type ls -F you can see which files are soft links because they end with @ To create a soft link called myfilelink.txt that points to a file called myfile.txt, use this: ln -s myfile.txt myfilelink.txt

  4. Soft and Hard Links Hard links Pointers to programs and files, but NOT directories If the original program or file is renamed, moved, or deleted, the hard link is NOT broken Hard links cannot span disk drives, so you CANNOT have a hard link on /dev/hdb that refers to a program or file on /dev/hda To create a hard link called myhardlink.txt that points to a file called myfile.txt, use this: ln myfile.txt myhardlink.txt

  5. Find Broken Links Code: (Bash) find . -type l | (while read FN ; do test -e "$FN" || ls -ld "$FN"; done) Code: (Just using find utility and test) find / -type l ! -exec test -r {} \; -print Description The find command finds all symbolic links in the current directory, “.”, and writes their names to its standard output. That gets piped into the parenthesized while loop, which tests each link. If the link points to an existing file, nothing happens, but if the link's target does not exist, the ls command gets executed and detailed information about the link and its intended target are sent to the standard output.

More Related