I am a new Linux user. Now I need to clean up a download directory of files, in fact, I just want to delete from the ~/download/folder except for files in the following format, other files:
1.*.iso-all ISO format files.2.*.zip-Files in all zip formats.
How do I remove a specific file from a bash shell on a linux,os X or unix-like system?
The Bash shell supports rich file pattern matching characters such as:
1.*-matches all the files.2.? -Matches a single letter in the file name.3.[...]-matches
1. Open the/ETC/BASH.BASHRC file with the VI editor (requires root permission)sudo vi/etc/bash.bashrcNext, you'll be prompted for a passwordAt this point vi may appear up and down problems, the solution:(1) Execute command sudo apt-get remove Vim-common(2) Execute command sudo apt-get install vim2. Locate the following code in the file#enable Bash completion in interactive shells#if! Shopt-oq POSIX; Then# if [-f/usr/share/bash-completion/bash_completi
In general, if you want to run a task over a long period of time, you need to use nohup or screen, what happens if you don't use it? To test the description: The scene 1:ssh login machine, by adding (), start the task to the background, exit by exiting the command, the task still exists scene 2:SSH login machine, by adding (), start the task to the background, directly close the SSH terminal (GUI directly fork out the window),The task terminates the test method and executes the following command
I am a new Linux user. Now I need to clean up a download directory of files, in fact, I just want to delete from the ~/download/folder in addition to the following format files so other files:
1.*.iso-All documents in ISO format.2.*.zip-All files in zip format.
How do I delete a particular file in a bash shell based on a linux,os X or unix-like system?
The Bash shell supports rich file pattern matching characters such as:
1.*-matches all the files.2.? -Matches a single letter in the filename
Linux anti-select Delete file
The easiest way is to # shopt-s Extglob (open Extglob mode)# RM-FR! (File1)If you want to exclude multiple, you can do this:# RM-RF! (File1|file2) LINUXRM Delete Other file method totals outside the specified fileFirst, Linux delete files and folders Common commands are as follows: Delete files: RM fileDelete folder: Rm-rf dirIt should be noted that rmdir can only delete empty folders. Delete all documents except the dev
1. Avoid directory spelling errorsshopt command:Demo:I want to go into the/home directory but accidentally spelled the wrong:[[email protected] ~]$ cd/hoem-BASH:CD:/hoem:no such file or directoryIf you use the shopt command, the situation is different:[Email protected] ~]$ shopt-s Cdspell[Email protected] ~]$ Cd/hoem/home[Email protected] home]$ pwd/homeThat's right!2. Delete all files or directories outsi
stopped. Jobs that have been stopped send sigcont signals to ensure they receive the sighup signal. To prevent the shell from sending a signal to a separate job, you should use the built-in command disown to remove it from the job table or use Disown-h to mark it as not receiving sighup.If the Huponexit option is set with the shopt command, Bash sends a sighup signal to all jobs when the interactive logon shell exits.If bash is waiting for the comman
1. Cat ~/.bash_history2. History | MoreEnter the keyboard----------lineSpace Keyboard---------------one page3,! 103 Execution of 103th orderProblemIn the process of using bash, we may want to .bash_history document more useful historical commands, so that we can query later, and here's a workaround. Change the default history> vi ~/.bashrc# 添加# 忽略[连续]重复命令HISTCONTROL=ignoredups# 清除重复命令# HISTCONTROL=erasedups# 忽略特定命令HISTIGNORE="[ ]*:ls:ll:cd:vi:pwd:sync:exit:history*"# 命令历史文件大小10MHISTFILESIZE=100
.:If you have the-i option, the shell executes interactively (interactive).-L:option allows bash to launch in a way similar to the login shell.-R:If you have the-r option, the shell becomes restricted (restricted).-S:If there is the-s option, or if there are no parameters remaining after the option is processed, the command is read from the standard input. This option allows you to set the positional parameters when starting an interactive shell.-D:Prints a list of strings in double quotation ma
10.1 Commond: Suppress normal shell function lookups
10.2 exec: Replacing the current shell process with the Execute command
10.3 Bash:gnu's Bourne-again shell interpreter
10.4 Builtin: Execute shell built-in command
10.5 Enable: Enables or disables built-in shell commands
10.6 Source: Reads and executes commands from the specified file in the current shell environment
10.7 Mksh: Command interpreter for interactive and shell scripts
10.8 Suspend: Pause shell execution
name [arg]
Hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern...]
History [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [elif
Jobs [-lnprs] [jobspec...] or job kill [-s sigspec |-n signum |-si
Let arg [arg...] local name [= value]...
Logout popd [+ N |-N] [-n]
Printf [-v var] format [arguments] pushd [dir | + N |-N] [-n]
Pwd [-LP] read [-ers] [-u fd] [-t timeout] [
Readonly [-af] [name [= value]...] return [n]
Select NAME [in WORDS...;] do CO set [-- abefhkmnptuvxBCHP] [-o opti
Shif
them, you need to copy them to the appropriate directory mysql/bin.#./Mysql. server start
How does Sun Solariys automatically enable mysql upon startup?Write a start and close batch processing file Web (under the path/etc/init. d). The content is as follows:
#! /Bin/shOPT _ = $1
Case "$ OPT _" inStart)/Bin/echo "$0: (start )"## Your service startup command goes here.#/Usr/local/apache/bin/apachectl start/Home3/mysql/bin/safe_mysqld-O join_buffer = 12
-0.08] # Perl makefile. pl mp_apxs =/usr/sbin/apxsEnter command to execute matlab [/usr/local/bin/Matlab-nodisplay-nojvm]:You cannot press enter here. I use the find command and find that the MATLAB command is in/usr/local/Matlab/bin/MATLAB. Therefore, I manually enter: /usr/local/Matlab/bin/Matlab-nodisplay-nojvmAfter you press enter, the following message is displayed:Attempting to run MATLAB... which: No shopt in (/usr/lib/qt-3.3/bin:/usr/Kerberos/
Variables and strings
Bash shell does not have the so-called "Data Form" unless the built-in declare is used to specify the variable type. In Bash shell, there is only one data type: A string consisting of Characters
Use it without having to go through the stated procedure
After the variable value is set, the variable value is valid only in the current shell environment. Variable name length is unlimited, case sensitive.
Variable setting method: variable name = value, but the good habit is to en
the Programme command complementing function to work on your terminal, you only need to execute the following/etc/bash_completionYou can:
#./etc/bash_completion
You can also cancel/etc/bash.bashrc(From Ubuntu Linux 13.04). In this way, you do not need to execute the above command:
### enable bash completion in interactive shells
if! shopt -oq posix;then
if[-f /usr/share/bash-completion/bash_completion ];then
./usr/share/bash-completion/bash_c
:
$ vi ~/.bashrc
Add the following lines.
[...]shopt -s cdspell
Enter: wq to save and exit the file.
Finally, run the following command to update the changes.
$ source ~/.bashrc
Now, if there are any spelling errors in the path when using the cd command, it will automatically correct and enter the correct directory.
As you can see in the preceding command, I intentionally entered an error (Donloads instead of Downloads), but Bash automatically detecte
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.