MacOS Shell Programming Notes

Source: Internet
Author: User

2. MacOS does not support ll (need to use LS-L implementation), in fact ll under Linux is ls-l shortcut keys.

LS Displays the file in the current directory.

LS-L Displays the file details in the current directory.

#以下命令均不包含 ".", "..." Directories, and the "." The beginning of the hidden file, if required, ll need to add the-a parameter # number of files in the current directory, do not include subdirectories ll |grep "^-" |wc-l# the current directory number, do not include subdirectories ll |grep "^d" |wc-l# the current directory number of files, including subdirectories ll-r| grep "^-" |wc-l# the number of directories under the current directory, including subdirectories Ll-r|grep "^d" |wc-l

1. Traversing the Directory

#!/bin/bashfunction Getdir () {for    element in ' ls $ '    do          dir_or_file=$1 "/" $element        if [-D $dir _or_file ]        then             getdir $dir _or_file        else            echo $dir _or_file        fi      done}root_dir= "/home/test" Getdir $ Root_dir

MacOS Shell Programming Notes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.