Avevo deciso di imparare qualche comando per il terminale, data la frustrazione continua di dover fare click infiniti per eseguire azioni basilari, come creare un file .txt tramite la GUI.
Per la base ho scelto di utilizzare una delle tante cheat sheet disponibili sul web, ma l'ho modificata un po' per soddisfare le mie esigenze.
(indice )
Go to the beginning of the line you are currently typing on.
This also works for most text input fields system wide. Netbeans being one exception
Go to the end of the line you are currently typing on.
This also works for most text input fields system wide. Netbeans being one exception
Cut everything backwards to beginning of line
Cut everything forward to end of line
Cut one word backwards using white space as delimiter
Paste whatever was cut by the last cut command
Kill whatever you are running. Also clears everything on current line
Exit the current shell when no process is running, or send EOF to a the running process
Puts whatever you are running into a suspended background process. fg restores it
(Underscore. So it's actually Ctrl + Shift + minus)
Swap the last two characters before the cursor
Move cursor one character forward
Move cursor one character backward
Move cursor one word forward
Move cursor one word backward
Swap the last two words before the cursor
Cut one word backwards using none alphabetic characters as delimiters
Auto-complete files and folder names
(indice )
Change directory e.g. cd Documents
cd [folder]change directory
lslist [Plumkewe-MacBook:desktop Plumkewe$ ls
GitHub Scripts
Other
School
Screenshots
ls -llist list [Plumkewe-MacBook:desktop Plumkewe$ ls -l
total 0
drwxr-xr-x@ 33 Plumkewe staff 1056 Aug 22 01:59 GitHub
drwxr-xr-x 199 Plumkewe staff 6368 Aug 22 00:23 Other
drwxr-xr-x 10 Plumkewe staff 320 Jul 30 00:12 School
drwxr-xr-x@ 86 Plumkewe staff 2752 Aug 19 13:37 Screenshots
drwxr-xr-x 8 Plumkewe staff 256 Aug 22 02:40 Scripts
Listing incl. hidden files
ls -alist list list [Plumkewe-MacBook:desktop Plumkewe$ ls -a
. .DS_Store .localized Other Screenshots
.. .idea GitHub School Scripts
Long listing with Human readable file sizes
ls -lhlist [Plumkewe-MacBook:desktop Plumkewe$ ls -lh
total 0
drwxr-xr-x@ 33 Plumkewe staff 1.0K Aug 22 01:59 GitHub
drwxr-xr-x 199 Plumkewe staff 6.2K Aug 22 00:23 Other
drwxr-xr-x 10 Plumkewe staff 320B Jul 30 00:12 School
drwxr-xr-x@ 86 Plumkewe staff 2.7K Aug 19 13:37 Screenshots
drwxr-xr-x 8 Plumkewe staff 256B Aug 22 02:40 Scripts
Entire content of folder recursively
ls -Rlist [Plumkewe-MacBook:desktop Plumkewe$ ls -R
GitHub Other School Screenshots Scripts
./GitHub:
Kitsune-Translations
...
./GitHub/Kitsune-Translations:
Localizations README.md
...
Run command with the security privileges of the superuser (Super User DO)
sudo [command]super user do
Opens a file ( as if you double clicked it )
Displays active processes. Press q to quit
toptable of processes Processes: 384 total, 2 running, 382 sleeping, 1423 threads 02:52:38
Load Avg: 1.79, 1.65, 1.69 CPU usage: 0.94% user, 1.53% sys, 97.51% idle
SharedLibs: 224M resident, 45M data, 60M linkedit.
MemRegions: 126075 total, 2045M resident, 76M private, 741M shared.
PhysMem: 8162M used (2925M wired), 28M unused.
VM: 6183G vsize, 2317M framework vsize, 53980655(0) swapins, 56295739(0) swapout
Networks: packets: 12928380/15G in, 13852515/6460M out.
Disks: 16802996/431G read, 35391275/428G written.
PID COMMAND %CPU TIME #TH #WQ #PORT MEM PURG CMPRS PGRP
64950 top 1.9 00:01.42 1/1 0 26 4504K 0B 0B 64950
Opens the file using the nano editor
nano [file]Nano's ANOther editor
Opens the file using the vim editor
Resets the terminal display
(indice )
Run command A and then B, regardless of success of A
Run command B if A succeeded
[command-a] && [command-b]
\ | [command-b] | Run command B if A failed
[command-a] || [command-b]
Run command A in background
(indice )
[command-b] | Run command A and then pass the result to command B e.g ps auxwww \ | grep google
[command-a] | [command-b]
(indice )
Shows the stuff typed – add a number to limit the last n items
history n[Plumkewe-MacBook:desktop Plumkewe$ history 4
519 ls -R
520 top
521 nano readme.md
522 history 4
Interactively search through previously typed commands
Execute the last command typed that starts with ‘value’
![value][Plumkewe-MacBook:desktop Plumkewe$ !to
touch readme.md
Print to the console the last command typed that starts with ‘value’
![value]:p[Plumkewe-MacBook:desktop Plumkewe$ !t:p
touch readme.md
Execute the last command typed
!![Plumkewe-MacBook:desktop Plumkewe$ !!
touch readme.md
Print to the console the last command typed
!!:p[Plumkewe-MacBook:desktop Plumkewe$ !!
touch readme.md
(indice )
Full path to working directory
pwdprint working directory [Plumkewe-MacBook:desktop Plumkewe$ pwd
/Users/Plumkewe/desktop
Current folder, e.g. ls .
.[Plumkewe-MacBook:desktop Plumkewe$ ls .
GitHub School Scripts
Other Screenshots readme.md
Parent/enclosing directory, e.g. ls ..
Long listing of parent directory
ls -l ..list [Plumkewe-MacBook:desktop Plumkewe$ ls ..
Applications Public
Bootstrap Studio Backups README.md
CLionProjects WebstormProjects
cd ../../change directory
Remove a file, e.g. rm data.tmp
rm -i [file]remove [Plumkewe-MacBook:desktop Plumkewe$ rm -i readme.md
remove readme.md? n/y
Remove a directory and contents
Force removal without confirmation
Move/Rename, e.g. mv file1.ad /tmp
mv [file] [new filename]move [Plumkewe-MacBook:desktop Plumkewe$ mv CIA.txt novabb.txt
Copies file contents to clipboard
pbcopy < [file]pasteboard copy
Paste clipboard contents into file, pbpaste > paste-test.txt
pbpaste > [file]pasteboard paste
(indice )
mkdir [dir]make directory
Create nested directories
mkdir -p [dir]/[dir]make directory
Remove directory ( only operates on empty directories )
rmdir [dir]remove directory
Remove directory and contents
Output file content delivered in screensize chunks
Push output to file, keep in mind it will get overwritten
Append output to existing file
Tell command to read content from a file
(indice )
Search for files, e.g. find /Users -name "file.txt"
find [dir] -name [search_pattern]find
Search for all lines that contain the pattern, e.g. grep "Tom" file.txt
grep [search_pattern] [file]globally search a regular expression and print
Recursively search in all files in specified directory for all lines that contain the pattern
grep -r [search_pattern] [dir]globally search a regular expression and print
Search for all lines that do NOT contain the pattern
grep -v [search_pattern] [file]globally search a regular expression and print
Search for all lines that contain the case-insensitive pattern
grep -i [search_pattern] [file]globally search a regular expression and print
Spotlight search for files (names, content, other metadata), e.g. mdfind skateboard
mdfind [search_pattern]metadata find
Spotlight search for files named like pattern in the given directory
mdfind -onlyin [dir] -name [pattern]metadata find
(indice )
[command] -hhelp [Plumkewe-MacBook:desktop Plumkewe$ cd --help
-bash: cd: --: invalid option
cd: usage: cd [-L|-P] [dir]
[command] --helphelp [Plumkewe-MacBook:desktop Plumkewe$ cd --help
-bash: cd: --: invalid option
cd: usage: cd [-L|-P] [dir]
info [command]information
Show the help manual for [command]
Gives a one-line description of [command]
whatis [command]what is [Plumkewe-MacBook:desktop Plumkewe$ whatis grep
grep(1), egrep(1), fgrep(1), zgrep(1), zegrep(1), zfgrep(1) - file pattern searcher
grep(1), egrep(1), fgrep(1), rgrep(1), bzgrep(1), bzegrep(1), bzfgrep(1), zgrep(1), zegrep(1), zfgrep(1) - file pattern searcher
git-grep(1) - Print lines matching a pattern
Searches for command with keywords in description
apropos [search-pattern][Plumkewe-MacBook:desktop Plumkewe$ apropos write
BIO_get_buffer_num_lines(3ssl), BIO_set_read_buffer_size(3ssl), BIO_set_write_buffer_size(3ssl), BIO_set_buffer_size(3ssl), ...