Paste a few scripts that I usually use.-Linux general technology-Linux programming and kernel information. The following is a detailed description. #! /Bin/bash
# Find a text in all files of the directory, include the subdirs
# Usage: finddir text
PWD = $ (pwd)
DIR = $ (du-a $ PWD | cut-f2)
#! /Bin/bash
# Link all file and directory in the source directory to target directory
# Usage: linkdir sourcedir targetdir
Source = $1
Target = $2
FILE =$ (ls $1)
For I in $ FILE
Do
Ln-s $ source/$ I $ target/$ I
Done
#! /Bin/bash
# Remove all directory in the current dir
# Usage: removedir
Name = $ (ls)
Echo "wait ..."
For I in $ name
Do
If [-d $ I]
Then
Echo "removing $ I"
Rm-fr $ I
Fi
Done
Echo "done! "
#! /Bin/bash
# Rename all files in the current dir with a same prefix, keep the surffix of files
# Renamefile prefix
Count = 0
Files = $ (ls)
Name = ""
Prefix = $ *
Suffix = ""
For I in $ files
Do
# The file renamefile must be excluded!
If [$ I! = "Renamefile"-a-f $ I]
Then
# Cut the suffix of file
Suffix = $ (echo $ I | cut-d.-f2)
Count = $ (expr $ count + 1)
Name = $ prefix $ count "." $ suffix
Mv $ I $ name
Fi
Done
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.