mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-25 00:50:15 +08:00
20140607-7 选题
This commit is contained in:
parent
82fd3503e0
commit
80a6a9f6c3
@ -0,0 +1,21 @@
|
||||
Steam Hits The Big 500 For Linux Games
|
||||
================================================================================
|
||||

|
||||
|
||||
That is one heck of a milestone isn't it? 500 Linux compatible games are now on Steam which is a pretty great number to point anyone at. No longer will people keep stating "but Linux has no games", but sadly they will say Linux has very little AAA games which is true, but this will be a gradual build up of course.
|
||||
|
||||
I keep saying this, but I still never thought we would make it to a day like this. We have XCOM, Civilization and many more still to come with some surprise announcements later this year I've no doubt.
|
||||
|
||||
Once the Steam Machines/SteamOS are released, and if they are successful we should see the number rise even quicker.
|
||||
|
||||
So, how long before we hit 1000? End of the year maybe, who knows!
|
||||
|
||||
I will go get my party hat now...are you celebrating this milestone?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.gamingonlinux.com/articles/steam-hits-the-big-500-for-linux-games.3849
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
@ -0,0 +1,110 @@
|
||||
Linux: Bash Delete All Files In Directory Except Few
|
||||
================================================================================
|
||||

|
||||
|
||||
I'm a new Linux system user. I need to cleanup in a download directory i.e. delete all files from ~/Downloads/ folders except the following types:
|
||||
|
||||
*.iso - All iso images files.
|
||||
*.zip - All zip files.
|
||||
|
||||
How do I delete all file except some in bash shell on a Linux, OS X or Unix-like systems?
|
||||
|
||||
Bash shell supports rich file pattern matching such as follows:
|
||||
|
||||
- * - Match any files.
|
||||
- ? - Matches any single character in filenames.
|
||||
- [...] - Matches any one of the enclosed characters.
|
||||
|
||||
### Method #1: Say hello to extended pattern matching operators ###
|
||||
|
||||
You need to use the extglob shell option using the shopt builtin command to use extended pattern matching operators such as:
|
||||
|
||||
1. ?(pattern-list) - Matches zero or one occurrence of the given patterns.
|
||||
1. *(pattern-list) - Matches zero or more occurrences of the given patterns.
|
||||
1. +(pattern-list) - Matches one or more occurrences of the given patterns.
|
||||
1. @(pattern-list) - Matches one of the given patterns.
|
||||
1. !(pattern-list) - Matches anything except one of the given patterns.
|
||||
|
||||
A pattern-list is nothing but a list of one or more patterns (filename) separated by a |. First, turn on extglob option:
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
#### Bash remove all files except *.zip and *.iso files ####
|
||||
|
||||
The rm command syntax is:
|
||||
|
||||
## Delete all file except file1 ##
|
||||
rm !(file1)
|
||||
|
||||
## Delete all file except file1 and file2 ##
|
||||
rm !(file1|file2)
|
||||
|
||||
## Delete all file except all zip files ##
|
||||
rm !(*.zip)
|
||||
|
||||
## Delete all file except all zip and iso files ##
|
||||
rm !(*.zip|*.iso)
|
||||
|
||||
## You set full path too ##
|
||||
rm /Users/vivek/!(*.zip|*.iso|*.mp3)
|
||||
|
||||
## Pass options ##
|
||||
rm [options] !(*.zip|*.iso)
|
||||
rm -v !(*.zip|*.iso)
|
||||
rm -f !(*.zip|*.iso)
|
||||
rm -v -i !(*.php)
|
||||
|
||||
Finally, turn off extglob option:
|
||||
|
||||
shopt -u extglob
|
||||
|
||||
### Method #2: Using bash GLOBIGNORE variable to remove all files except specific ones ###
|
||||
|
||||
From the [bash(1)][1] page:
|
||||
|
||||
> A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a pathname expansion pattern also matches one of the patterns in GLOBIGNORE, it is removed from the list of matches.
|
||||
|
||||
To delete all files except zip and iso files, set GLOBIGNORE as follows:
|
||||
|
||||
## only works with BASH ##
|
||||
cd ~/Downloads/
|
||||
GLOBIGNORE=*.zip:*.iso
|
||||
rm -v *
|
||||
unset GLOBIGNORE
|
||||
|
||||
### Method #3: Find command to rm all files except zip and iso files ###
|
||||
|
||||
If you are using tcsh/csh/sh/ksh or any other shell, try the following find command syntax on a Unix-like system to delete files:
|
||||
|
||||
find /dir/ -type f -not -name 'PATTERN' -delete
|
||||
|
||||
OR
|
||||
|
||||
## deals with weird file names using xargs ##
|
||||
find /dir/ -type f -not -name 'PATTERN' -print0 | xargs -0 -I {} rm {}
|
||||
find /dir/ -type f -not -name 'PATTERN' -print0 | xargs -0 -I {} rm [options] {}
|
||||
|
||||
To delete all files except php files in ~/sources/ directory, type:
|
||||
|
||||
find ~/sources/ -type f -not -name '*.php' -delete
|
||||
|
||||
OR
|
||||
|
||||
find ~/sources/ -type f -not -name '*.php' -print0 | xargs -0 -I {} rm -v {}
|
||||
|
||||
The syntax to delete all files except *.zip and *.iso is as follows:
|
||||
|
||||
find . -type f -not \( -name '*zip' -or -name '*iso' \) -delete
|
||||
|
||||
For more information see [bash command man page][1] and [find command man page][2].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.cyberciti.biz/faq/linux-bash-delete-all-files-in-directory-except-few/
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://www.manpager.com/linux/man1/bash.1.html
|
||||
[2]:http://www.manpager.com/linux/man1/find.1.html
|
Loading…
Reference in New Issue
Block a user