recentpopularlog in

aries1988 : bash   84

« earlier  
Initiation au Shell
Quand on parle du Shell, on fait souvent référence à l'interpréteur de commande, autrefois nommé sh (contraction de shell), et qui a ensuite donné naissance à tout un éventail d'interpréteurs tels que bash, csh, zsh, ksh… qu'il ne faut pas confondre avec un émulateur de terminal comme xterm, eterm, gnome-terminal qui est un outil graphique qui permet d'avoir accès au shell.
primer  bash  definition 
december 2018 by aries1988
A Beautifully Productive Terminal Experience
Every developer can benefit from using the command line. Whether you use it to bounce between projects or create complex scripts, getting familiar with the c...
bash  tool 
september 2018 by aries1988
Stephen  on Twitter
“youtube-dl 真好用~支援一大堆網站影片下載,YouTube、B 站、蘋果日報、愛奇藝通通有~”
tool  bash  download  youtube  video 
september 2018 by aries1988
macos - OS X / Linux: pipe into two processes? - Stack Overflow
As tee copy to each file and also to standard output , and as >() will be see by tee as files, you have to write: prg1 | tee >(prg2) > >(prg3) to not dump the ouptut of prg1 on console (notice the supplementary >). – F. Hauri Oct 1 '13 at 21:00
bash  tee  explained  tips 
july 2018 by aries1988
vim - How to insert spaces up to column X to line up things in columns? - Stack Overflow
If you are using a unix-like environment, you can use the command line tool column. Mark your lines using visual mode, then:

:'<,'>!column -t
bash  column  vim  howto 
march 2018 by aries1988
regex - Regular Expression usage with ls - Stack Overflow
You are confusing regular expression with shell globbing.
bash  explained  regex 
january 2018 by aries1988
快速学习Bash - Vamei


$echo $varIsGood



$echo $((2 + (5*2)))







bash  tutorial 
december 2017 by aries1988
New keyboard shortcuts;
Paste from clipboard (Ctrl-V).
Incremental history search (Ctrl-R/Ctrl-S).
Powerful completion (TAB).
Undo (Ctrl-Z).
Automatic “cd ..” (Ctrl-Alt-U).
Environment variable expansion (Ctrl-Alt-E).
(press Alt-H for many more…)
windows  bash  cmd  tool  moi 
march 2017 by aries1988
osx - How to change the terminal prompt to just current directory? - Stack Overflow
.bashrc is ONLY excuted when starting a sub-shell. bash login shell uses the following initialization scripts:

bash  explained  bashrc 
november 2015 by aries1988
bash - Find directories that DON'T contain a file - Ask Ubuntu
Case 2: You want to be more flexible

You're not sure of the case, and the extension might be jPg, png...

find base_dir -mindepth 2 -maxdepth 2 -type d '!' -exec sh -c 'ls -1 "{}"|egrep -i -q "^cover\.(jpg|png)$"' ';' -print

You need to spawn a shell sh for each directory since piping isn't possible when using find
ls -1 "{}" outputs just the filenames of the directory find is currently traversing
egrep (instead of grep) uses extended regular expressions; -i makes the search case insensitive, -q makes it omit any output
bash  explained 
november 2015 by aries1988
ubuntu 12.04 - How to run rsync without staying logged in? - Server Fault
Run the command within GNU Screen. Basically:

Install screen: $ sudo apt-get install screen
Run screen: $ screen ... at which point, you'll have a shell running from within screen.
Run your command.
Press Ctrl-A,d, which will detach you from the screen session and your command will continue running.
When you want to re-attach, just ssh in as the user who owns the screen session and then:

$ screen -RD
bash  terminal 
july 2015 by aries1988
What’s the Difference Between Single and Double Quotes in the Bash Shell?
Double Quotes

Use when you want to enclose variables or use shell expansion inside a string.
All characters within are interpreted as regular characters except for $ or ` which will be expanded on the shell.
Single Quotes

All characters within single quotes are interpreted as a string character.
bash  explained 
may 2015 by aries1988
version control - Detect the OS from a Bash script - Stack Overflow
if [[ "$unamestr" == 'Linux' ]]; then
elif [[ "$unamestr" == 'FreeBSD' ]]; then
os  bash  example 
march 2013 by aries1988
scripting - How do I do if statement arithmetic in bash? - Stack Overflow
read n
if ! ((n % 4)); then
echo "$n divisible by 4."
The (( )) operator evaluates expressions as C arithmetic, and has a boolean return.

Hence, (( 0 )) is false, and (( 1 )) is true. [1]

The $(( )) operator also expands C arithmetic expressions, but instead of returning true/false, it returns the value instead. Because of this you can test the output if $(( )) in this fashion: [2]

[[ $(( n % 4 )) == 0 ]]
But this is tantamount to: if (function() == false). Thus the simpler and more idiomatic test is:

! (( n % 4 ))
[1]: Modern bash handles numbers up to your machine's intmax_t size.

[2]: Note that you can drop $ inside of (( )), because it dereferences variables within.
bash  learn  arithmetic 
february 2013 by aries1988
Keyboard Shortcuts for Bash ( Command Shell for Ubuntu, Debian, Suse, Redhat, Linux, etc) - How-To Geek
Ctrl AGo to the beginning of the line you are currently typing on Ctrl EGo to the end of the line you are currently typing on Ctrl L              Clears the Screen, similar to the clear command Ctrl UClears the line before the cursor position. If you are at the end of the line, clears the entire line. Ctrl HSame as backspace Ctrl RLet’s you search through previously used commands Ctrl CKill whatever you are running Ctrl DExit the current shell Ctrl ZPuts whatever you are running into a suspended background process. fg restores it. Ctrl WDelete the word before the cursor Ctrl KClear the line after the cursor Ctrl TSwap the last two characters before the cursor Esc TSwap the last two words before the cursor Alt FMove cursor forward one word on the current line Alt BMove cursor backward one word on the current line TabAuto-complete files and folder names
linux  shortcuts  via:jkprime  bash 
february 2013 by aries1988
BASH: How to Redirect Output to File, AND Still Have it on Screen
ls -l 2>&1 >file.txt
will send stderr to your screen and stdout to file.txt. Why? Because stderr was redirected to the same place as stdout, but at this time stdout was still pointing to the console. stdout was not redirected to file.txt until AFTER stderr had been redirected. When we are talking AFTER in this example we are talking about placement on the command line. Things specified further to the right are thought of as coming after. So this example does nothing for stderr. stderr is indeed redirected to the same place as stdout, which is the console at the time of the redirection, but stderr was ALREADY pointing there in the first place - resulting in no perceivable change.

It makes sense in the light of the shell's operation. The "|" is actioned in "3. Parses the tokens into simple and compound commands" and the ">"s are actioned in "5. Performs any necessary redirections ..." so, in this case, the ls command's stdout is already configured for redirection to the tee command by the time the ">"s are processed.
bash  linux  output  howto  explained 
december 2012 by aries1988
linux - Why does find -exec mv {} ./target/ + not work? - Stack Overflow
find -exec command {} ;

For each result, command {} is executed. All occurences of {} are replaced by the filename. ; is prefixed with a slash to prevent the shell from interpreting it.

find -exec command {} +

Each result is appended to command and executed afterwards. Taking the command length limitations into account, I guess that this command may be executed more times, with the manual page supporting me:
bash  linux  workflow 
october 2012 by aries1988
mtime option in find command
find ~ -mtime 1 -exec ls -ld --time-style=iso {} ;
bash  ls  find  rm 
october 2012 by aries1988
OCR - Extract Scanned Text From PDF
# - ocrpdf - Extract scanned text from a PDF file using Tesseract,
# Poppler and ImageMagick.
# Check if all necessary executables are installed
# Check if exist the file and is a pdf
# People that use graphical file managers happily use names like
# "This is my file.pdf" and include brackets, commas, non ascii
# symbols. And in some cases slashes too! Then they send this file
# like an email attachment and it travels across different machines
# and programs, protocols, encodings, character sets, etc. Despite
# most today operating systems and programs are able to get rid of
# this, it is not a good practice.
# Cleaning some weird symbols from file's name
# Convert pdf to ppm images
# Convert PPM images to TIF. If you use TIFF (two efs) tesseract
# returns an error
# Convert tif images to plain text
# Join txt files
# End ocrpdf
filename  example  bash 
september 2012 by aries1988
下面是Kristóf Kovács收集的28个Unix/Linux下的28个命令行下的工具(原文链接),有一些是大家熟悉的,有一些是非常有用的,有一些是不为人知的。这些工具都非常不错,希望每个人都知道。本篇文章还在Hacker News上被讨论,你可以过去看看。我以作者的原文中加入了官网链接和一些说明。
googlereader  linux  bash 
july 2012 by aries1988
Extract Scanned Text From PDF
Extract scanned text from a PDF file using Tesseract, Poppler and ImageMagick.
Advice about the scripts included in this site: try to understand what the script does and attempt to write your own version. If you just cut and paste the next time you'll have to visit my stupid site again ;-). Remember, it's not free software but to learn what makes you free.
bash  example  filename  pdf  oct  linux  howto  script 
may 2012 by aries1988
Manipulating Strings
Deletes shortest match of $substring from back of $string.
bash  string  linux 
october 2011 by aries1988
« earlier      
per page:    204080120160

Copy this bookmark:

to read