Common shell instances

Source: Internet
Author: User

Tag: Shell

1. Search for all files larger than 500 mb in the current directory, write these file names to a text file, and count the number of files.

Find/-size + 500 m-type F | tee/root/file.txt | WC-l or find/-size + 50 m-exec ls {}\;>/root/test.txt

2. Find 100 files starting with ABC in the directory/tmp, and save the first line of these files to the file new.

for filename in `find /tmp -type f -name "abc*"|head -n 100`dosed -n ‘1p‘ $filename >> newdone

3. check whether a file is a block or character device file. If it is copied to the/dev directory

read -p "input a file:" filenameif [ -b $filename -o -c $filename ]thencp $filename /dev/fi

4. Save all rows in file B but not in file a as file C and count the number of lines in file C.

[[email protected] ~]# cat a dddddddddssssssss3333333333333eeeeeeeeee[[email protected] ~]# cat bdddddddddd444444444tttttttttt[[email protected] ~]# grep -xvf a b | tee c | wc -l3


This article from the "from the Heart" blog, please be sure to keep this source http://fuquanjun.blog.51cto.com/5820068/1432400

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.