Created
March 28, 2025 06:37
-
-
Save RajaniCode/ee886cf3db4024ba62ab8853dee600bb to your computer and use it in GitHub Desktop.
Shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################################################################### | |
# touch # cat # tee # tac # sed # echo | |
########################################################################################################################### | |
# mkdir -p "A/B" | |
% touch File.txt | |
% touch "A/B/File.txt" | |
% mkdir -p "A/B" && touch A/B/File.txt | |
% cat File.txt | |
% cat "A/B/File.txt" | |
% mkdir -p "A/B" && cat > A/B/px-mongo-sc.yaml << EOF | |
kind: StorageClass | |
apiVersion: storage.k8s.io/v1beta1 | |
metadata: | |
name: px-ha-sc | |
provisioner: kubernetes.io/portworx-volume | |
parameters: | |
repl: "3" | |
io_profile: "db_remote" | |
priority_io: "high" | |
fs: "xfs" | |
EOF | |
# NB # cat # \$ # \` | |
% mkdir -p "A/B" && cat > A/B/index.js << EOF | |
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get('/', (req, res) => { | |
res.send("Node.js Version: " + process.version + "\n"); | |
}); | |
app.listen(port, () => { | |
console.log(\`Server started on port \${port}\`); | |
}); | |
EOF | |
# NB # cat # \$ # \` | |
% mkdir -p "A/B" && cat << EOF > A/B/index.js | |
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get('/', (req, res) => { | |
res.send("Node.js Version: " + process.version + "\n"); | |
}); | |
app.listen(port, () => { | |
console.log(\`Server started on port \${port}\`); | |
}); | |
EOF | |
# NB # cat # \$ # \` | |
% mkdir -p "A/B" && cat << EOF | tee A/B/index.js | |
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get('/', (req, res) => { | |
res.send("Node.js Version: " + process.version + "\n"); | |
}); | |
app.listen(port, () => { | |
console.log(\`Server started on port \${port}\`); | |
}); | |
EOF | |
# NB # echo # Single Quotes | |
% echo 'Hello, World!' > source.txt | |
% echo 'Hello World!' >> source.txt | |
% cat source.txt > destination.txt | |
% cat source.txt >> destination.txt | |
% cat source.txt destination.txt > destination2.txt | |
% cat source.txt > destination.txt > destination2.txt | |
% cat > file.txt << EOF | |
Alpha | |
Beta | |
Gamma | |
Delta | |
EOF | |
% cat file.txt | more | |
% cat file.txt | less | |
% cat -v file.txt | sort | |
% cat -v file.txt | sort -r | |
% cat -n file.txt | |
% cat -n file.txt | tail -1 | |
% cat file.txt | wc -l | |
% tac file.txt | |
[ | |
% mkdir -p macOSAArch64/Scala | |
% cd macOSAArch64/Scala | |
% echo 'object method { def main(args: Array[String]) = { println("Main Method Scala Version Number String: " + util.Properties.versionNumberString) } }' > program.scala | |
] | |
% mkdir -p "macOSAArch64/Scala" && cat > macOSAArch64/Scala/program.scala << EOF | |
object method { def main(args: Array[String]) = { println("Main Method Scala Version Number String: " + util.Properties.versionNumberString) } } | |
EOF | |
[ | |
% mkdir -p macOSAArch64/Scala3 | |
% echo '@main def method() = println("Main Method Scala Version Number String: " + util.Properties.versionNumberString)' > program.scala | |
] | |
% mkdir -p "macOSAArch64/Scala3" && cat > macOSAArch64/Scala3/program.scala << EOF | |
@main def method() = println("Main Method Scala Version Number String: " + util.Properties.versionNumberString) | |
EOF | |
% man cat | |
% man cd | |
% export LANG="en_US.UTF-8" | |
# Or | |
% export LC_CTYPE="en_US.UTF-8" | |
% man cd > mancd | |
% cat mancd | |
% sort file.txt | |
% sort -r file.txt | |
% wc -l file.txt | |
# Delete last line of file | |
% cat file.txt | |
% sed -i '' '$d' file.txt | |
% cat file.txt | |
% sed -n '=' file.txt | |
% sed -n '$=' file.txt | |
% awk 'END { print NR }' file.txt | |
% grep -c ".*" file.txt | |
% grep -c \^ file.txt | |
% grep -Hc ".*" file.txt | |
% nl file.txt | |
% nl file.txt | tail -1 | awk '{print $1}' | |
% perl -lne 'END { print $. }' file.txt | |
# scp – OpenSSH secure file copy | |
% man scp | |
% tail File.txt | |
% tail -r File.txt | |
# tail -f # log | |
% tail -f /Library/Logs/Multipass/multipassd.log | |
# Clear contents of file | |
% echo -n > file.txt | |
% stat | |
% mkdir -p "A/B" && stat "A/B" | |
% stat File.txt | |
% ipconfig getifaddr en0 | |
% ifconfig | grep inet | |
% ifconfig | grep inet | grep 192.168 | |
% ipconfig getifaddr en0 | tee >> A/B/t.txt | |
% ls | tee >> A/B/t.txt | |
% cat A/B/t.txt | |
% dotnet --version | tee > A/B/d.txt | |
% mkdir -p "A/B" && dotnet --version | tee > A/B/d.txt | |
% cat A/B/d.txt | |
# For the given executable | |
[ | |
% mono | tee t.txt | |
] | |
% echo $0 | |
$ echo $0 | |
# printf # echo | |
Alpha | |
&& Beta | |
! | |
% printf "Alpha\n&& Beta\n\!\n" | |
$ printf "Alpha\n&& Beta\n!" | |
% echo "Alpha\n&& Beta\n\!" | |
$ echo -e "Alpha\n&& Beta\n!" | |
> (echo Hello && echo ^&^& World && echo !) | |
% clear | |
$ clear | |
> cls | |
# arguments.sh | |
#!/bin/bash | |
echo "First argument: $1" | |
echo "Second argument: $2" | |
# arguments.bat | |
REM Batch Script | |
@echo off | |
@echo First argument: %1 | |
@echo Second argument: %2 | |
########################################################################################################################### | |
########################################################################################################################### | |
# vim | |
########################################################################################################################### | |
# Insert Mode | |
Esc | |
i | |
# Write and Quit | |
Esc | |
:wq | |
# Quit Without Writing | |
Esc | |
:q! | |
# Empty File | |
Esc | |
gg [This will take the cursor to the first line of the file.] | |
d+g [Keep pressing the keys till the last line is reached.] | |
# Undo | |
Esc | |
u | |
# Redo | |
Ctrl+R | |
# Copy Paste from Clipboard | |
Esc | |
i | |
Shift+Insert or Click the mouse middle button (usually the wheel) or Press Ctrl + Shift + V to Paste [Check if the first line is pasted correctly.] | |
########################################################################################################################### | |
########################################################################################################################### | |
# nano | |
########################################################################################################################### | |
# nano Save | |
% nano Text.txt | |
<control + X> | |
<Y> | |
<return> | |
# nano WriteOut | |
% nano Text.txt | |
<control + O> | |
# File Name | |
<return> | |
<control + X> | |
########################################################################################################################### | |
########################################################################################################################### | |
# chmod # chown | |
########################################################################################################################### | |
*************************************************************************************************************************** | |
=========================================================================================================================== | |
# chmod | |
=========================================================================================================================== | |
# Grant permission for the file to run as an executable | |
$ sudo chmod +x ./dotnet-install.sh | |
$ sudo chmod 755 gradlew* | |
[ | |
$ ./dotnet-install.sh | |
$ sh dotnet-install.sh | |
$ bash dotnet-install.sh | |
] | |
=========================================================================================================================== | |
# chown | |
=========================================================================================================================== | |
[ | |
# Add the Microsoft repository to the system's sources list | |
wget https://packages.microsoft.com/config/$ID/$VERSION_ID/prod.list | |
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list | |
] | |
# Set ownership | |
$ sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg | |
$ sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list | |
$ sudo chown -R vagrant:vagrant MongoDB_Spark_Course | |
=========================================================================================================================== | |
*************************************************************************************************************************** | |
# macOS # chmod # Change file modes or Access Control Lists | |
*************************************************************************************************************************** | |
=========================================================================================================================== | |
# The chmod utility modifies the file mode bits of the listed files as specified by the mode operand. | |
# It may also be used to modify the Access Control Lists (ACLs) associated with the listed files. | |
=========================================================================================================================== | |
# MODES # Modes may be absolute or symbolic | |
=========================================================================================================================== | |
# An absolute mode is an octal number constructed from the sum of one or more of the following values | |
=========================================================================================================================== | |
4000 (the setuid bit). Executable files with this bit set will run with effective uid set to the uid of the file owner. | |
Directories with this bit set will force all files and sub-directories created in them to be owned by the directory | |
owner and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and | |
the suiddir option to mount(8). | |
2000 (the setgid bit). Executable files with this bit set will run with effective gid set to the gid of the file owner. | |
1000 (the sticky bit). See chmod(2) and sticky(7). | |
0400 Allow read by owner. | |
0200 Allow write by owner. | |
0100 For files, allow execution by owner. For directories, allow the owner to search in the directory. | |
0040 Allow read by group members. | |
0020 Allow write by group members. | |
0010 For files, allow execution by group members. For directories, allow group members to search in the directory. | |
0004 Allow read by others. | |
0002 Allow write by others. | |
0001 For files, allow execution by others. For directories allow others to search in the directory. | |
=========================================================================================================================== | |
# SAMPLE VALID MODES | |
=========================================================================================================================== | |
644 make a file readable by anyone and writable by the owner only. | |
go-w deny write permission to group and others. | |
=rw,+X set the read and write permissions to the usual defaults, but retain any execute permissions that are currently set. | |
+X make a directory or file searchable/executable by everyone if it is already searchable/executable by anyone. | |
755 | |
u=rwx,go=rx | |
u=rwx,go=u-w make a file readable/executable by everyone and writable by the owner only. | |
go= clear all mode bits for group and others. | |
g=u-w set the group bits equal to the user bits, but clear the group write bit. | |
=========================================================================================================================== | |
# Change file permissions # chmod 755 <file or folder> # read, write, and execute | |
% chmod 755 Program.exe | |
% chmod 755 $HOME/Desktop/Working/Java/JavaCS/Generics | |
% chmod u=rwx,g=rx,o=rx public/images | |
% chmod 777 public/images | |
=========================================================================================================================== | |
# chmod 775 vs. chmod 755 | |
# chmod 775 | |
# Only the group to which the current user belongs can [write] | |
# Anyone can [modify/overwrite] including the ones they didn't create as long as the owner is one of their group members | |
# chmod 755 | |
# Only the owner can [write] | |
# Anyone can [read/execute] | |
# chmod 777 vs. chmod 755 | |
# chmod 777 | |
# Anyone can [read/write/execute] (execute on a directory means running 'ls' to list directory contents) | |
# Should be used on a file only for debugging | |
# chmod 755 is more secure than chmod 775 which in turn is more secure than chmod 777 | |
# chmod 664 vs. chmod 644 | |
# chmod 664 | |
# Only owner/group members can [write] others can only [read] | |
# No one can [execute] | |
# chmod 644 | |
# Only the owner can [write] others can only [read] | |
# No one can [execute] | |
=========================================================================================================================== | |
Permission Binary value Decimal value | |
=========================================================================================================================== | |
No permission (—) 000 0 | |
Execute only (–x) 001 1 | |
Write only (-w-) 010 2 | |
Read only (r–) 100 4 | |
Write and execute (-wx) 011 3 | |
Read and execute (r-x) 101 5 | |
Read and write (rw-) 110 6 | |
Read, write, and execute (rwx) 111 7 | |
=========================================================================================================================== | |
*************************************************************************************************************************** | |
# macOS # chown # Change file owner and group | |
*************************************************************************************************************************** | |
=========================================================================================================================== | |
# The chown utility changes the user ID and/or the group ID of the specified files. | |
# Symbolic links named by arguments are silently left unchanged unless -h is used. | |
=========================================================================================================================== | |
# Change directory ownership # chown -R $[username]:[username] [directorypath] | |
% chown -R $USER $HOME/Desktop/Java | |
=========================================================================================================================== | |
*************************************************************************************************************************** | |
########################################################################################################################### | |
########################################################################################################################### | |
# curl # wget | |
########################################################################################################################### | |
*************************************************************************************************************************** | |
# curl # wget # https | |
*************************************************************************************************************************** | |
# curl: (60) SSL certificate problem: unable to get local issuer certificate | |
# More details here: https://curl.se/docs/sslcerts.html | |
# -k | |
% curl -k https://localhost:44303/ | |
# ERROR: cannot verify localhost's certificate, issued by ‘CN=localhost’: | |
# Self-signed certificate encountered. | |
# To connect to localhost insecurely, use `--no-check-certificate'. | |
# --no-check-certificate | |
% wget -S -O - https://localhost:44303/ --no-check-certificate | |
*************************************************************************************************************************** | |
# curl # wget # http | |
*************************************************************************************************************************** | |
% curl http://localhost:5015/ | |
% wget -S -O - http://localhost:5015/ | |
[ | |
% python3 manage.py runserver | |
] | |
# Redirect | |
% curl -L http://127.0.0.1:8000/admin/ | |
% wget -S -O - http://127.0.0.1:8000/admin/ | |
*************************************************************************************************************************** | |
# curl | |
*************************************************************************************************************************** | |
% curl -L -o swift-wasm-5.10.0-RELEASE-macos_arm64.pkg https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-macos_arm64.pkg | |
# --location # Or -L | |
% curl --location https://storage.googleapis.com/minikube-site-examples/ingress-example.yaml | |
% curl -L https://storage.googleapis.com/minikube-site-examples/ingress-example.yaml | |
# -o # <Name> | |
% curl -o Node.png "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" | |
# -O # Rename | |
% curl -O "https://avatars.githubusercontent.com/u/9950313?s=48&v=4"; mv 9950313 Node.png | |
# --output # <Name> | |
% curl --output Node.png "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" | |
# -o # <Name> | |
% curl -o Node.png "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" | |
# --create-dirs --output-dir | |
% curl --output Node.png "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" --create-dirs --output-dir public/images | |
# -H | |
% curl -H 'Host: www.example.com' http://93.184.216.34 | |
# bash | |
% curl https://wasmtime.dev/install.sh -sSf | bash | |
% curl -o install.sh https://wasmtime.dev/install.sh -sSf; sudo chmod +x ./install.sh; ./install.sh | |
*************************************************************************************************************************** | |
# wget | |
*************************************************************************************************************************** | |
% wget https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-macos_arm64.pkg | |
# --directory-prefix # Or # -P | |
% wget https://raw.githubusercontent.com/tachyons-css/tachyons/master/css/tachyons.min.css --directory-prefix=public | |
% wget https://raw.githubusercontent.com/tachyons-css/tachyons/master/css/tachyons.min.css --directory-prefix="public" | |
% wget https://raw.githubusercontent.com/tachyons-css/tachyons/master/css/tachyons.min.css --directory-prefix="$HOME/Kubernetes/minikube/node-mongodb-app/public" | |
% wget "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" --directory-prefix="public/images" | |
% wget "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" -P "public/images" | |
# --output-document # Or # -O | |
% wget --output-document=Node.png "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" | |
% wget -O Node.png "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" | |
# --output # And # && mv | |
# Instead of | |
# --output # And # --directory-prefix | |
% wget --output-document=Node.png "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" && mv Node.png "public/images" | |
% wget -O Node.png "https://avatars.githubusercontent.com/u/9950313?s=48&v=4" && mv Node.png "public/images" | |
# bash | |
% wget -O - https://wasmtime.dev/install.sh | bash | |
% wget https://wasmtime.dev/install.sh -v -O install.sh; sudo chmod +x ./install.sh; ./install.sh | |
*************************************************************************************************************************** | |
########################################################################################################################### | |
########################################################################################################################### | |
# nslookup # dig # ifconfig # scutil # dns-sd # dscacheutil # dns-sd # host | |
########################################################################################################################### | |
[ | |
% open https://www.nslookup.io/domains/example.com/webservers/ | |
% open https://www.nslookup.io/domains/www.example.com/webservers/ | |
] | |
# nslookup # query Internet name servers interactively | |
% nslookup example.com | |
% nslookup www.example.com | |
[ | |
% curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' | |
% curl -s http://checkip.dyndns.org | |
] | |
# dig # DNS lookup utility | |
% dig +short example.com | |
% dig +short www.example.com | |
% dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | |
% open https://www.whatismybrowser.com | |
% open https://www.whois.com/whois/google.com | |
[ | |
% curl ifconfig.me | |
] | |
# ifconfig – configure network interface parameters | |
% ifconfig | |
% ifconfig | grep en1 | |
% ifconfig | grep en0 | |
% ifconfig | grep inet | |
# ipconfig – view and control IP configuration state | |
# ipconfig | |
[ | |
% ipconfig getifaddr en1 | |
% ipconfig getifaddr en0 | |
] | |
# scutil # Manage system configuration parameters | |
% scutil --get ComputerName | |
% scutil --dns | |
% scutil -r example.com | |
% scutil -r www.example.com | |
% scutil -W -r example.com | |
% scutil -W -r www.example.com | |
# dns-sd # Multicast DNS (mDNS) & DNS Service Discovery (DNS-SD) Test Tool | |
% dns-sd -G v4v6 example.com | |
% dns-sd -G v4v6 www.example.com | |
# dscacheutil # Gather information, statistics and initiate queries to the Directory Service cache | |
% dscacheutil -q host -a name example.com | |
% dscacheutil -q host -a name www.example.com | |
# dns-sd # Multicast DNS (mDNS) & DNS Service Discovery (DNS-SD) Test Tool | |
% dns-sd -q example.com | |
% dns-sd -q www.example.com | |
% nslookup example.com | |
# 23.192.228.80 | |
[ | |
% curl -H 'Host: example.com' http://23.192.228.80 | |
] | |
% nslookup www.example.com | |
# 23.200.238.48 | |
[ | |
% curl -H 'Host: www.example.com' http://23.200.238.48 | |
] | |
# host # DNS lookup utility | |
% host -t cname www.example.com | |
[ | |
www.example.com is an alias for www.example.com-v4.edgesuite.net. | |
] | |
% host -t cname www.github.com | |
[ | |
www.github.com is an alias for github.com. | |
] | |
% host -t cname www.abc.xyz | |
[ | |
www.abc.xyz is an alias for www3.l.google.com. | |
] | |
% host -t cname www.aws.amazon.com | |
[ | |
www.aws.amazon.com is an alias for www.cname-proxy.amazon.com. | |
] | |
% host -t cname www.azure.microsoft.com | |
[ | |
www.azure.microsoft.com is an alias for acom-vanity-router-prod-glbl-01.trafficmanager.net. | |
] | |
########################################################################################################################### | |
########################################################################################################################### | |
# open | |
########################################################################################################################### | |
% open https://www.google.com | |
% open -n -a "Google Chrome" --args "--new-window" "https://google.com" | |
% open -n -a "Microsoft Edge" --args "--new-window" "https://google.com" | |
% open -n -a "Firefox" --args "--new-window" "https://google.com" | |
% open -n -a "Opera" --args "--new-window" "https://google.com" | |
% open -n -a "DuckDuckGo" --args "--new-window" "https://google.com" | |
% open -n -a "Google Chrome" --args "--new-window" "https://google.com" -incognito | |
% open -n -a "Microsoft Edge" --args "--new-window" "https://google.com" -inprivate | |
% open -n -a "Opera" --args "--new-window" "https://google.com" -private | |
[ | |
% open -n -a "Google Chrome" --args "--new-window" file:///$HOME/surefire.html | |
] | |
########################################################################################################################### | |
########################################################################################################################### | |
# File # Folder # copy # move # rename | |
########################################################################################################################### | |
# Copy File | |
$ cp "E:\Working\Java\Spring\Samples\Spring4MVCHibernateExample\SpringHibernateExample\target\SpringHibernateExample.war" "C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps" | |
> copy "E:\Working\Java\Spring\Samples\Spring4MVCHibernateExample\SpringHibernateExample\target\SpringHibernateExample.war" "C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps" | |
# Copy Folder | |
$ cp -r "E:\Working\Java\Spring\Samples\Spring4MVCHibernateExample\SpringHibernateExample\target\SpringHibernateExample" "C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\SpringHibernateExample" | |
> xcopy "E:\Working\Java\Spring\Samples\Spring4MVCHibernateExample\SpringHibernateExample\target\SpringHibernateExample" "C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\SpringHibernateExample" /s /e /y /i | |
# Move File | |
$ mv "E:\Working\Java\Spring\Samples\Spring4MVCHibernateExample\SpringHibernateExample\target\SpringHibernateExample.war" "C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps" | |
> move "E:\Working\Java\Spring\Samples\Spring4MVCHibernateExample\SpringHibernateExample\target\SpringHibernateExample.war" "C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps" | |
# Move Folder | |
$ mv "E:\Working\Java\Spring\Samples\Spring4MVCHibernateExample\SpringHibernateExample\target\SpringHibernateExample" "C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\SpringHibernateExample" | |
> move "E:\Working\Java\Spring\Samples\Spring4MVCHibernateExample\SpringHibernateExample\target\SpringHibernateExample" "C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\SpringHibernateExample" | |
# Rename File | |
$ mv oldfile.txt newfile.txt | |
# Note that you cannot specify a new drive or path for your destination file | |
> rename oldfile.txt newfile.txt | |
> ren oldfile.txt newfile.txt | |
# Rename Folder | |
$ mv oldfolder newfolder | |
> rename oldfolder newfolder | |
> ren oldfolder newfolder | |
########################################################################################################################### | |
########################################################################################################################### | |
# find | |
########################################################################################################################### | |
# Default # find recursively # directories in pre-order i.e. before their contents # not a breadth-first traversal | |
# -depth # find recursively # directories are visited in post-order # all entries in a directory will be acted on before the directory itself # depth-first traversal | |
# -maxdepth 1 # current directory # at most 1 directory level | |
# Find files with leading and trailing whitespace | |
% find . -type f -depth \( -name ' *' -o -name '* .*' \) | |
% find . -type f \( -name ' *' -o -name '* .*' \) | |
# Find folders with leading and trailing whitespace | |
% find . -type d -depth \( -name ' *' -o -name '* ' \) | |
% find . -type d \( -name ' *' -o -name '* ' \) | |
# Remove leading whitespace from files | |
% find . -type f -depth -name ' *' -execdir bash -c 'f=${1#./}; mv "./$f" "./${f#"${f%%[![:space:]]*}"}"' Move {} \; | |
# Remove leading whitespace from folders | |
% find . -type d -depth -name ' *' -execdir bash -c 'f=${1#./}; mv "./$f" "./${f#"${f%%[![:space:]]*}"}"' Move {} \; | |
# Remove trailing whitespace from files | |
# NB | |
# Files might have multiple extensions | |
% find . -type f -name '* *' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); fn="${1%.*}"; fe="${1##*.}"; src="${fn}.${fe}"; tgt="${fn%"${fn##*[^[:space:]]}"}.${fe}"; \ | |
mv "${src}" "${tgt}"' _ {} \; | |
# Remove trailing whitespace from folders | |
% find . -type d -depth -name '* ' -execdir bash -c 'mv "$1" "${1%"${1##*[^[:space:]]}"}"' Move {} \; | |
# File names # recursively | |
% find . -type f -exec basename {} \; | |
# Folder names # recursively | |
% find . -type d -exec basename {} \; | |
# Find and delete file named ".DS_Store" | |
% find . -type f -depth -iname ".DS_Store" -print | |
% find . -type f -depth -iname ".DS_Store" -delete | |
# Find and delete file named "__MACOSX" | |
% find . -type d -depth -iname "__MACOSX" | while read d; do printf "$d\n"; done | |
% find . -type d -depth -iname "__MACOSX" | while read d; do rm -rf "$d"; done | |
*************************************************************************************************************************** | |
# Files # Remove # Replace # Characters | |
*************************************************************************************************************************** | |
# Remove & | |
# default # find recursively # directories in pre-order i.e. before their contents # not a breadth-first traversal | |
% find . -type f -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//&/}"' _ {} \; | |
# Remove & | |
# -depth # find recursively # directories are visited in post-order # all entries in a directory will be acted on before the directory itself # depth-first traversal | |
% find . -type f -depth -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//&/}"' _ {} \; | |
# Remove & | |
# -maxdepth 1 # current directory # at most 1 directory level | |
% find . -type f -maxdepth 1 -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//&/}"' _ {} \; | |
# Remove / # Or # : | |
% find . -type f -name '*:*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//:/''}" ' _ {} \; | |
# Remove \ | |
% find . -type f -name '*\\*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//\\/}"' _ {} \; | |
# Remove ? | |
% find . -type f -name '*?*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//\?/}"' _ {} \; | |
# Filename Extension | |
% find . -type f -name '*.*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
echo "${1##*.}" ' _ {} \; | |
# Filename Without Extension | |
% find . -type f -name '*.*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
echo "${1%.*}" ' _ {} \; | |
# Filename With Extension | |
% find . -type f -name '*.*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
echo "${1%.*}"."${1##*.}" ' _ {} \; | |
# Filename With Extension # & | |
% find . -type f -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); fn="${1%.*}"; fe="${1##*.}"; \ | |
echo "$fn.$fe" ' _ {} \; | |
# Filename With Extension # Remove & | |
% find . -type f -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); fn="${1%.*}"; fe="${1##*.}"; \ | |
mv "$fn.$fe" "${fn//&/}.$fe"' _ {} \; | |
# Filename With Extension # Remove . | |
% find . -type f -name '*.*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); fn="${1%.*}"; fe="${1##*.}"; src="${fn}.${fe}"; tgt=".${fn//./}.${fe}"; \ | |
mv "${src}" "${tgt}"' _ {} \; | |
# Replace & [With] and | |
# -depth # find recursively # directories are visited in post-order # all entries in a directory will be acted on before the directory itself # depth-first traversal | |
% find . -type f -depth -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//&/and}"' _ {} \; | |
# Replace <space><space>[With] <space> | |
# -depth # find recursively # directories are visited in post-order # all entries in a directory will be acted on before the directory itself # depth-first traversal | |
% find . -type f -depth -name '* *' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1// / }"' _ {} \; | |
*************************************************************************************************************************** | |
# Folders # Remove # Replace # Characters | |
*************************************************************************************************************************** | |
# Remove & | |
# -depth # find recursively # directories are visited in post-order # all entries in a directory will be acted on before the directory itself # depth-first traversal | |
% find . -type d -depth -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f//&/}"' _ {} \; | |
# Remove & | |
# -maxdepth 1 # current directory # at most 1 directory level | |
% find . -type d -maxdepth 1 -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f//&/}"' _ {} \; | |
# Replace & [With] and | |
# -depth # find recursively # directories are visited in post-order # all entries in a directory will be acted on before the directory itself # depth-first traversal | |
% find . -type d -depth -name '*&*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f//&/and}"' _ {} \; | |
# Replace <space><space>[With] <space> | |
# -depth # find recursively # directories are visited in post-order # all entries in a directory will be acted on before the directory itself # depth-first traversal | |
% find . -type d -depth -name '* *' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f// / }"' _ {} \; | |
*************************************************************************************************************************** | |
# Rename files by replacing substring # <++> with <PP> # files # current directory | |
[ | |
% mkdir -p "C++ A1/C++ A2/C++ A3" | |
% mkdir -p "C++ B1/C++ B2/C++ B3" | |
% touch "C++ TextA.txt" | |
% touch "C++ TextB.txt" | |
% touch "C++ A1/C++ TextA1.txt" | |
% touch "C++ B1/C++ TextB1.txt" | |
% touch "C++ A1/C++ A2/C++ A2.txt" | |
% touch "C++ B1/C++ B2/C++ B2.txt" | |
% touch "C++ A1/C++ A2/C++ A3/C++ A3.txt" | |
% touch "C++ B1/C++ B2/C++ B3/C++ B3.txt" | |
] | |
% tree | |
[ | |
. | |
├── C++ A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A2.txt | |
│  │  └── C++ A3 | |
│  │  └── C++ A3.txt | |
│  └── C++ TextA1.txt | |
├── C++ B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B2.txt | |
│  │  └── C++ B3 | |
│  │  └── C++ B3.txt | |
│  └── C++ TextB1.txt | |
├── C++ TextA.txt | |
└── C++ TextB.txt | |
7 directories, 8 files | |
] | |
% find . -type f -maxdepth 1 -name '*++*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//++/PP}" ' _ {} \; | |
% tree | |
[ | |
. | |
├── C++ A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A2.txt | |
│  │  └── C++ A3 | |
│  │  └── C++ A3.txt | |
│  └── C++ TextA1.txt | |
├── C++ B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B2.txt | |
│  │  └── C++ B3 | |
│  │  └── C++ B3.txt | |
│  └── C++ TextB1.txt | |
├── CPP TextA.txt | |
└── CPP TextB.txt | |
7 directories, 8 files | |
] | |
# Rename files by replacing substring # <PP> with <++> # files # current directory # file extension | |
% find . -type f -maxdepth 1 -name '*PP*'.txt -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//PP/++}" ' _ {} \; | |
% tree | |
[ | |
. | |
├── C++ A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A2.txt | |
│  │  └── C++ A3 | |
│  │  └── C++ A3.txt | |
│  └── C++ TextA1.txt | |
├── C++ B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B2.txt | |
│  │  └── C++ B3 | |
│  │  └── C++ B3.txt | |
│  └── C++ TextB1.txt | |
├── C++ TextA.txt | |
└── C++ TextB.txt | |
7 directories, 8 files | |
] | |
# Or | |
% for i in *++*.txt; do [[ -e ${i/++/PP} ]] || mv "$i" "${i/++/PP}"; done | |
% tree | |
[ | |
. | |
├── C++ A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A2.txt | |
│  │  └── C++ A3 | |
│  │  └── C++ A3.txt | |
│  └── C++ TextA1.txt | |
├── C++ B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B2.txt | |
│  │  └── C++ B3 | |
│  │  └── C++ B3.txt | |
│  └── C++ TextB1.txt | |
├── CPP TextA.txt | |
└── CPP TextB.txt | |
7 directories, 8 files | |
] | |
# Rename files and folders by replacing substring # replace <++> with <PP> # files & folders # current directory | |
% for i in *++*; do [[ -e ${i/++/PP} ]] || mv "$i" "${i/++/PP}"; done | |
% tree | |
[ | |
. | |
├── CPP A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A2.txt | |
│  │  └── C++ A3 | |
│  │  └── C++ A3.txt | |
│  └── C++ TextA1.txt | |
├── CPP B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B2.txt | |
│  │  └── C++ B3 | |
│  │  └── C++ B3.txt | |
│  └── C++ TextB1.txt | |
├── CPP TextA.txt | |
└── CPP TextB.txt | |
7 directories, 8 files | |
] | |
# Rename folders by replacing substring # <PP> with <++> # folders # current directory | |
% find . -type d -maxdepth 1 -name '*PP*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "${1//PP/++}" ' _ {} \; | |
% tree | |
[ | |
. | |
├── C++ A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A2.txt | |
│  │  └── C++ A3 | |
│  │  └── C++ A3.txt | |
│  └── C++ TextA1.txt | |
├── C++ B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B2.txt | |
│  │  └── C++ B3 | |
│  │  └── C++ B3.txt | |
│  └── C++ TextB1.txt | |
├── CPP TextA.txt | |
└── CPP TextB.txt | |
7 directories, 8 files | |
] | |
# Rename files by replacing substring # <++> with <PP> # recursively | |
% find . -type f -depth -name '*++*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f//++/PP}"' _ {} \; | |
% tree | |
[ | |
. | |
├── C++ A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A3 | |
│  │  │  └── CPP A3.txt | |
│  │  └── CPP A2.txt | |
│  └── CPP TextA1.txt | |
├── C++ B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B3 | |
│  │  │  └── CPP B3.txt | |
│  │  └── CPP B2.txt | |
│  └── CPP TextB1.txt | |
├── CPP TextA.txt | |
└── CPP TextB.txt | |
7 directories, 8 files | |
] | |
# Rename files by replacing substring # <PP> with <++> # recursively # file extension | |
% find . -type f -depth -name '*PP*'.txt -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f//PP/++}"' _ {} \; | |
% tree | |
[ | |
. | |
├── C++ A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A2.txt | |
│  │  └── C++ A3 | |
│  │  └── C++ A3.txt | |
│  └── C++ TextA1.txt | |
├── C++ B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B2.txt | |
│  │  └── C++ B3 | |
│  │  └── C++ B3.txt | |
│  └── C++ TextB1.txt | |
├── C++ TextA.txt | |
└── C++ TextB.txt | |
7 directories, 8 file | |
] | |
# Rename folders by replacing substring # <++> with <PP> # recursively | |
% find . -type d -depth -name '*++*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f//++/PP}"' _ {} \; | |
% tree | |
[ | |
. | |
├── C++ TextA.txt | |
├── C++ TextB.txt | |
├── CPP A1 | |
│  ├── C++ TextA1.txt | |
│  └── CPP A2 | |
│  ├── C++ A2.txt | |
│  └── CPP A3 | |
│  └── C++ A3.txt | |
└── CPP B1 | |
├── C++ TextB1.txt | |
└── CPP B2 | |
├── C++ B2.txt | |
└── CPP B3 | |
└── C++ B3.txt | |
7 directories, 8 files | |
] | |
# Rename files & folders by replacing substring # <++> with <PP> # recursively | |
% find . -depth -name '*++*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f//++/PP}"' _ {} \; | |
% tree | |
[ | |
. | |
├── CPP A1 | |
│  ├── CPP A2 | |
│  │  ├── CPP A2.txt | |
│  │  └── CPP A3 | |
│  │  └── CPP A3.txt | |
│  └── CPP TextA1.txt | |
├── CPP B1 | |
│  ├── CPP B2 | |
│  │  ├── CPP B2.txt | |
│  │  └── CPP B3 | |
│  │  └── CPP B3.txt | |
│  └── CPP TextB1.txt | |
├── CPP TextA.txt | |
└── CPP TextB.txt | |
7 directories, 8 files | |
] | |
# Rename by removing substring # <PP> # recursively | |
% find . -depth -name '*PP*' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f//PP/}"' _ {} \; | |
% tree | |
[ | |
. | |
├── C A1 | |
│  ├── C A2 | |
│  │  ├── C A2.txt | |
│  │  └── C A3 | |
│  │  └── C A3.txt | |
│  └── C TextA1.txt | |
├── C B1 | |
│  ├── C B2 | |
│  │  ├── C B2.txt | |
│  │  └── C B3 | |
│  │  └── C B3.txt | |
│  └── C TextB1.txt | |
├── C TextA.txt | |
└── C TextB.txt | |
7 directories, 8 files | |
] | |
# Rename by replacing # <space> with substring <++> # recursively | |
% find . -depth -name '* *' -exec bash -c \ | |
'f=$(basename "$1"); d=$(dirname "$1"); \ | |
mv "$1" "$d/${f// /++ }"' _ {} \; | |
% tree | |
[ | |
. | |
├── C++ A1 | |
│  ├── C++ A2 | |
│  │  ├── C++ A2.txt | |
│  │  └── C++ A3 | |
│  │  └── C++ A3.txt | |
│  └── C++ TextA1.txt | |
├── C++ B1 | |
│  ├── C++ B2 | |
│  │  ├── C++ B2.txt | |
│  │  └── C++ B3 | |
│  │  └── C++ B3.txt | |
│  └── C++ TextB1.txt | |
├── C++ TextA.txt | |
└── C++ TextB.txt | |
7 directories, 8 files | |
] | |
*************************************************************************************************************************** | |
# Find files with filename extension recursively | |
% find . -name "*.zip" -type f -print | |
% find . -empty -type f | while read d; do printf "$d\n"; done | |
> dir *.zip /s /p | |
# Find and print empty files (including file names with whitespace) recursively | |
% find . -type f -empty -print | |
% find . -empty -type f | while read f; do printf "$f\n"; done | |
> for /r %F in (*) do @if %~zF==0 echo "%F" | |
# Find and delete empty files (including file names with whitespace) recursively | |
% find . -type f -empty -delete | |
% find . -empty -type f | while read f; do rm -rf "$f"; done | |
> for /r %F in (*) do @if %~zF==0 del "%F" | |
# Find and list hidden (entries starting with .) files (including file names with whitespace) recursively | |
% find . -type f -iname ".*" -ls | |
> for /r %F in (.*) do @if %~zF==0 echo "%F" | |
# Find and delete hidden (entries starting with .) files (including file names with whitespace) recursively | |
% find . -type f -iname ".*" -delete | |
> for /r %F in (.*) do @if %~zF==0 del "%F" | |
# Find and print empty directories (including directory names with whitespace) recursively | |
% find . -type d -empty -print | |
> for /r /d %F in (.) do @dir /b "%F" | findstr "^" >nul || echo %~fF | |
# Find and delete empty directories (including directory names with whitespace) recursively | |
% find . -type d -empty -delete | |
> for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do rd "%d" | |
# Find and list hidden (entries starting with .) directories (including directory names with whitespace) recursively | |
% find . -type d -iname ".*" -ls | |
> dir ".*" /ad /b /s | |
# Find and delete hidden (entries starting with .) directories (including directory names with whitespace) recursively | |
% find . -mindepth 1 -type d -iname ".*" | while read d; do rm -rf "$d"; done | |
> for /d /r . %d in (.*) do @if exist "%d" rd /s/q "%d" | |
# Find and list unhidden (entries not starting with .) files (including file names with whitespace) recursively | |
% find . -type f -not -iname ".*" -ls | |
# Find and delete unhidden (entries not starting with .) files (including file names with whitespace) recursively | |
% find . -type f -not -iname ".*" -delete | |
# Find and list unhidden (entries not starting with .) directories (including directory names with whitespace) recursively | |
% find . -type d -not -iname ".*" -ls | |
# Find and delete unhidden (entries not starting with .) directories (including directory names with whitespace) recursively | |
$ find . -mindepth 1 -type d -not -iname ".*" | while read d; do rm -rf "$d"; done | |
# Find and print non-empty files (including file names with whitespace) recursively | |
$ find . -type f -not -empty -print | |
# while | |
$ find . -type f -not -empty | while read d; do printf "$d\n"; done | |
# Find and delete non-empty files (including file names with whitespace) recursively | |
$ find . -type f -not -empty -delete | |
# while | |
$ find . -type f -not -empty | while read f; do rm -rf "$f"; done | |
# Find and print empty directories (including directory names with whitespace) recursively | |
$ find . -type d -empty -print | |
# skipping '.' | |
$ find . -mindepth 1 -type d -empty -print | |
# Find and print non-empty directories (including directory names with whitespace) recursively | |
$ find . -type d -not -empty -print | |
# skipping '.' | |
$ find . -mindepth 1 -type d -not -empty -print | |
# while | |
$ find . -type d -not -empty | while read d; do printf "$d\n"; done | |
# skipping '.' | |
$ find . -mindepth 1 -type d -not -empty | while read d; do printf "$d\n"; done | |
# Find file name extensions | |
$ find . -name "*.zip" -type f -print | |
# Find and delete named files (including file names with whitespace) recursively | |
% find . -name "New Text Document.txt" -type f -delete | |
# while | |
$ find . -name "New Text Document.txt" -type f | while read f; do rm -rf "$f"; done | |
# Find and rename files (including file names with whitespace) recursively | |
$ find . -name "New Text Document.txt" -type f | while read NAME; do mv "${NAME}" "${NAME%.txt}s.txt"; done | |
# Undo | |
$ find . -name "New Text Documents.txt" -type f | while read NAME; do mv "${NAME}" "${NAME%s.txt}.txt"; done | |
# Find and delete files with named (file name extensions) recursively | |
% find . -name "*.zip" -type f -delete | |
# while | |
$ find . -name "*.zip" -type f | while read f; do rm -rf "$f"; done | |
# Find and print named directories (including those with whitespace) recursively | |
% find . -name "node_modules" -type d -print | |
# while | |
% find . -name "node_modules" -type d | while read d; do printf "$d\n"; done | |
% find . -name "bin" -type d | while read d; do printf "$d\n"; done | |
% find . -name "obj" -type d | while read d; do printf "$d\n"; done | |
% find . -name "_UpgradeReport_Files" -type d | while read d; do printf "$d\n"; done | |
# Directory names | |
% find . -name "node_modules" -type d -print | |
% find . -type d -empty -print | |
# Find and delete named directories (including directory names with whitespace) recursively | |
% find . -name "node_modules" -type d -delete | |
# find and delete named directories (including those with whitespace) recursively | |
% find . -name "node_modules" -type d | while read d; do rm -rf "$d"; done | |
# Find and rename directories (including directory names with whitespace) recursively | |
$ find . -name "*Download" -type d | while read NAME; do mv "${NAME}" "${NAME}s"; done | |
# Undo | |
$ find . -name "*Downloads" -type d | while read NAME; do mv "${NAME}" "${NAME%s}"; done | |
% find . -depth -type d -name "C#" -execdir mv {} "CS" \; | |
% find . -depth -type d -name "*C#*" -execdir mv {} "CS" \; | |
# find and print file names and their directory (including directory names with whitespace) having specified file size recursively | |
% find . -size +50M -print | |
% find . -size +100M -print | |
# Find and print file names and their size, date modified, directory having specified file size recursively | |
% find . -size +50M -type f -exec ls -lh {} \; | while read f; do printf "$f \n"; done | |
% find . -size +50M -type f -exec ls -lh {} \; | awk '{ print $9 " -Size : " $5 }' | |
% find . -size +50M -type f -exec ls -lh {} \; | awk {'printf ("%5s\t%s\n", $5, $9)'} | |
% find . -size +50M -type f -exec ls -lh {} \; | awk {'printf ("%5s -PATH: %s\n", $5, $9)'} | |
% find . -size +50M -type f -exec ls -lh {} \; | awk {'printf ("%0s -PATH: %s\n", $5, $9)'} | |
# Remove whitespace in files/directories | |
$ find -name "*" -print0 | sort -rz | while read -d $'\0' f; do mv -v "$f" "$(dirname "$f")/$(basename "${f// /}")"; done | |
# replace whitespace with "_" in files and directories | |
$ find -name "*" -print0 | sort -rz | while read -d $'\0' f; do mv -v "$f" "$(dirname "$f")/$(basename "${f// /_}")"; done | |
# Remove whitespace in filenames recursively # include (file name extension) to avoid affecting folders with same name | |
$ find -name "New Text Document.txt" -print0 | sort -rz | while read -d $'\0' f; do mv -v "$f" "$(dirname "$f")/$(basename "${f// /}")"; done | |
# replace whitespace with "_" in filenames recursively # include (file name extension) to avoid affecting folders with same name | |
$ find -name "New Text Document.txt" -print0 | sort -rz | while read -d $'\0' f; do mv -v "$f" "$(dirname "$f")/$(basename "${f// /_}")"; done | |
[ | |
# Remove whitespace # hidden # recursive # folders without whitespace | |
$ find . -name "New Text Document.txt" -type f | while read NAME; do mv "${NAME}" "${NAME//[[:space:]]}"; done | |
$ find . -name "New Text Document.txt" -type f | while read NAME; do mv "${NAME}" "${NAME// /}"; done | |
# Replace whitespace with "_" # hidden # folders without whitespace | |
$ find . -name "New Text Document.txt" -type f| while read NAME; do mv "${NAME}" "${NAME// /_}"; done | |
] | |
# Remove whitespace in folder names recursively # will affect files with same name | |
$ find -name "*White Space*" -print0 | sort -rz | while read -d $'\0' f; do mv -v "$f" "$(dirname "$f")/$(basename "${f// /}")"; done | |
# Replace whitespace with "_" in folder names recursively # will affect files with same name | |
$ find -name "*White Space*" -print0 | sort -rz | while read -d $'\0' f; do mv -v "$f" "$(dirname "$f")/$(basename "${f// /_}")"; done | |
[ | |
# Remove whitespace # hidden # non-recursive folders without whitespace | |
$ find . -name "*White Space*" -type d | while read NAME; do mv "${NAME}" "${NAME//[[:space:]]}"; done | |
$ find . -name "*White Space*" -type d | while read NAME; do mv "${NAME}" "${NAME// /}"; done | |
# Replace whitespace with "_" # hidden # non-recursive folders without whitespace | |
$ find . -name "*White Space*" -type d | while read NAME; do mv "${NAME}" "${NAME// /_}"; done | |
] | |
# Find and change (file name extensions) of files recursively | |
# .sh to .sh.txt | |
% find . -name "*.sh" -type f | while read NAME; do mv "${NAME}" "${NAME%.sh}.sh.txt"; done | |
# .sh.txt to .sh | |
% find . -name "*.sh.txt" -type f | while read NAME; do mv "${NAME}" "${NAME%.sh.txt}.sh"; done | |
# .sh to .txt | |
% find . -name "*.sh" -type f | while read NAME; do mv "${NAME}" "${NAME%.sh}.txt"; done | |
# .txt to .sh | |
% find . -name "*.txt" -type f | while read NAME; do mv "${NAME}" "${NAME%.txt}.sh"; done | |
# Find and change (file name extensions) of files recursively # uppercase to lowercase | |
# .PDF to .pdf | |
% find . -name "*.PDF" -type f | while read NAME; do mv "${NAME}" "${NAME%.PDF}.pdf"; done | |
# Find and change (file name extensions) of files recursively # lowercase to uppercase | |
# .pdf to .PDF | |
% find . -name "*.pdf" -type f | while read NAME; do mv "${NAME}" "${NAME%.pdf}.PDF"; done | |
[ | |
# Change (file name extensions) of files in current directory (non-recursively) | |
$ for file in *.sh; do mv "$file" "`basename "$file" .sh`.txt"; done | |
$ for file in *.txt; do mv "$file" "`basename "$file" .txt`.sh"; done | |
$ for file in *.sh; do mv "$file" "`basename "$file" .sh`.sh.txt"; done | |
$ for file in *.sh.txt; do mv "$file" "`basename "$file" .sh.txt`.sh"; done | |
] | |
[ | |
# Append ".txt" (file name extension) to file | |
$ find . -name "*.sh" -type f -exec mv "{}" "{}.txt" \; | |
] | |
[ | |
# Append "s" to directory name | |
$ find . -name "*Download" -type d -exec mv "{}" "{}s" \; | |
] | |
########################################################################################################################### | |
########################################################################################################################### | |
# List | |
########################################################################################################################### | |
# List files and directories excluding hidden (entries starting with .) with total (the current directory by default) # -a for all including hidden # -R for recursive | |
# usage: ls [-@ABCFGHILOPRSTUWabcdefghiklmnopqrstuvwxy1%,] [--color=when] [-D format] [file ...] | |
% ls | |
# List all files including hidden files (files with names beginning with a dot) | |
% ls -a | |
# Full listing, indicating what type files are by putting a slash after directories and a star after executable files (programs you can run) | |
% ls -F | |
# Long listing of all files | |
% ls -l | |
% ls -1a | |
% ls -lh | |
> dir | |
> dir /A | |
########################################################################################################################### | |
########################################################################################################################### | |
# zip # unzip # rar # p7zip # 7z # split | |
########################################################################################################################### | |
# zip with/without password, (rm) unzip # zip rar and unzip rar | |
# zip file | |
% zip "Kubernetes Secrets.pdf.zip" "Kubernetes Secrets.pdf" | |
# zip file with password | |
% zip -er "The Kubernetes Book.pdf.zip" "The Kubernetes Book.pdf" | |
# unzip file | |
% unzip "Kubernetes Secrets.pdf.zip" | |
# unzip password protected file # replace ...? [y]es, [n]o, [A]ll, [N]one, [r]ename: r | |
% unzip "The Kubernetes Book.pdf.zip" | |
# zip folder | |
% zip -r Rajani.zip Rajani | |
# zip folder with password | |
% zip -er "Cloud Computing.zip" "Cloud Computing" | |
# unzip folder | |
% unzip Rajani.zip | |
# unzip password protected folder # replace ...? [y]es, [n]o, [A]ll, [N]one, [r]ename: N | |
% unzip "Cloud Computing.zip" | |
# unzip password protected zipped file # unzip may require password (twice) % unzip "The Kubernetes Book.pdf.zip.zip" % unzip "The Kubernetes Book.pdf.zip" # [replace ...? [y]es, [n]o, [A]ll, [N]one, [r]ename: r | |
% zip -er "The Kubernetes Book.pdf.zip.zip" "The Kubernetes Book.pdf.zip" | |
# unzip password protected zipped folder # unzip may require password (twice) % unzip "Cloud Computing.zip.zip" % unzip "Cloud Computing.zip" # replace ...? [y]es, [n]o, [A]ll, [N]one, [r]ename: N | |
% zip -er "Cloud Computing.zip.zip" "Cloud Computing.zip" | |
# zip folders and files with password | |
% zip -er "Cloud Computing.zip" * | |
Enter password: | |
Verify password: | |
% rm -rf "Cloud Computing" | |
% unzip "Cloud Computing.zip" | |
Archive: Cloud Computing.zip | |
creating: Cloud Computing/ | |
[Cloud Computing.zip] Cloud Computing/OpenShift in Action.pdf password: | |
# split zip/rar into zips # Target size less than source size | |
% zip "Cloud Computing.zip" --out "Split Cloud Computing.zip" -s 75m | |
% zip "Cloud Computing.rar" --out "Split Cloud Computing.zip" -s 50m | |
# < 50m | |
% zip "sampledata.archive.zip" --out "Split sampledata.archive.zip" -s 45m | |
# zip # unzip # p7zip # 7z | |
% zip | |
% unzip | |
# p7zip | |
% brew install p7zip | |
% 7z | |
% where 7z | |
% whereis 7z | |
% which 7z | |
% type 7z | |
% man 7z | |
[ | |
# Files With Size > | |
% find . -depth -size +50M -print | |
[ | |
% find . -depth -size +100M -print | |
] | |
% find . -depth -size +50M -type f -exec ls -lh {} \; | awk {'printf ("%0s -PATH: %s\n", $5, $9)'} | |
# Zip | |
% zip "openjdk-20-jextract+1-2_macos-x64_bin.tar.gz.zip" "openjdk-20-jextract+1-2_macos-x64_bin.tar.gz" | |
# Split Zip = 45 MB | |
% zip "openjdk-20-jextract+1-2_macos-x64_bin.tar.gz.zip" --out "Split openjdk-20-jextract+1-2_macos-x64_bin.tar.gz.zip" -s 45m | |
# Merge Zip # Extract Split Archive | |
% 7z x "Split openjdk-20-jextract+1-2_macos-x64_bin.tar.gz.zip" | |
# Size > 50 MB # Delete | |
% find . -depth -size +50M -delete | |
] | |
# encrypt | |
[ | |
# File | |
% zip -er "openjdk-20-jextract+1-2_macos-x64_bin.tar.gz.zip" "openjdk-20-jextract+1-2_macos-x64_bin.tar.gz" | |
% unzip "openjdk-20-jextract+1-2_macos-x64_bin.tar.gz.zip" | |
# Folder | |
% zip -er "OpenJDK Jextract.zip" "OpenJDK Jextract" | |
% unzip "OpenJDK Jextract.zip" | |
] | |
########################################################################################################################### | |
########################################################################################################################### | |
# tar | |
########################################################################################################################### | |
# -xf: .tar.bz2, .tar.xz | |
# -xvzf: tar.gz, .tar.gx, .tgz | |
# -xvzf # -xzvf # xzvf # xvfz # -xvzf # -xvf | |
# default # extract to [current] directory | |
# -C # extract to [existing] directory | |
# -x Extract | |
# -v, --verbose | |
# -z, --gunzip, --gzip | |
# -f --file [last option] | |
# tar extract # rename # recursively | |
# -C existing directory | |
% mkdir -p swift-for-wasm-wat-example && tar -xvzf swift-for-wasm-examples-main.zip -C swift-for-wasm-wat-example --strip-components 1 | |
[ | |
# unzip # rename # recursively | |
% unzip swift-for-wasm-examples-main.zip -d swift-for-wasm-wat-example | |
] | |
########################################################################################################################### | |
########################################################################################################################### | |
# macOS | |
########################################################################################################################### | |
*************************************************************************************************************************** | |
# Terminal | |
*************************************************************************************************************************** | |
# Terminal > Settings > Profiles > Homebrew > Window | |
Terminal Limit number of restored rows to: 2,888,888,888 | |
# Terminal # Rosetta | |
% arch | |
% arch -x86_64 zsh | |
% arch | |
% arch -arm64 zsh | |
% arch | |
# Or | |
Macintosh HD/Applications/Utilities/Terminal.app | |
Get Info | |
Check/Uncheck Open using Rosetta | |
Restart the computer | |
# ProductName # ProductVersion # BuildVersion | |
% sw_vers | |
% sw_vers -productName | |
% sw_vers -productVersion | |
% sw_vers -buildVersion | |
# sw_vers # Listen | |
% say $(sw_vers) | |
% say $(sw_vers -productName && sw_vers -productVersion | sed 's/10//') | |
% say $(sw_vers -productName && sw_vers -productVersion) | |
# macOS name | |
% awk '/SOFTWARE LICENSE AGREEMENT FOR macOS/' '/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf' | awk -F 'macOS ' '{print $NF}' | awk '{print substr($0, 0, length($0)-1)}' | |
# Hardware and Software Configuration | |
% system_profiler | |
% system_profiler | less | |
% system_profiler SPSoftwareDataType | |
# SystemVersion.plist file | |
% cat /System/Library/CoreServices/SystemVersion.plist | |
# .SystemVersionPlatform.plist file | |
% cat /System/Library/CoreServices/.SystemVersionPlatform.plist | |
# IOPlatformSerialNumber | |
% ioreg -l | grep IOPlatformSerialNumber | |
[ | |
| "IOPlatformSerialNumber" = "LPQ7CH2PWY" | |
] | |
# Software Update Tool | |
% softwareupdate --list | |
# Manage system configuration parameters | |
% scutil --dns | |
% scutil --proxy | |
% scutil --nc list | |
# sysctl – get or set kernel state | |
% man sysctl | |
% sysctl -a | |
# screen - screen manager with VT100/ANSI terminal emulation | |
% screen | |
[Press Space or Return to end] | |
# nohup – invoke a utility immune to hangups | |
% nohup sleep 10 && echo Hola! | |
% ls | |
% cat nohup.out | |
% rm -rf nohup.out | |
# Hide item from GUI | |
% mkdir -p folder | |
% echo 'Hello, World!' > file.txt | |
% chflags hidden folder | |
% chflags hidden file.txt | |
% chflags hidden * | |
# Unhide item from GUI | |
% chflags nohidden folder | |
% chflags nohidden file.txt | |
% chflags nohidden * | |
# Launchpad Application Alias | |
% ls $HOME/Applications | |
# To view the DNS configuration used by this system, use: scutil | |
% sudo nano /etc/resolv.conf | |
[ | |
# | |
# macOS Notice | |
# | |
# This file is not consulted for DNS hostname resolution, address | |
# resolution, or the DNS query routing mechanism used by most | |
# processes on this system. | |
# | |
# To view the DNS configuration used by this system, use: | |
# scutil --dns | |
# | |
# SEE ALSO | |
# dns-sd(1), scutil(8) | |
# | |
# This file is automatically generated. | |
# | |
nameserver 2401:4900:7b89:87fb::50 | |
nameserver 192.168.5.147 | |
] | |
# Kindle | |
% ls $HOME/Library/Containers/com.amazon.Lassen/Data/Library/eBooks | |
# youtube-dl # Download # Playlist # mp4 | |
% youtube-dl "https://www.youtube.com/watch?v=_zenG90idAA&list=PLdeR_B79JGkxlQfx6v_899TTRQZx2pbr9&ab_channel=Alluxio" | |
# Path/Folder/File | |
% youtube-dl -o "$HOME/Downloads/Apache/Spark.mp4" "https://www.youtube.com/watch?v=VZ7EHLdrVo0&ab_channel=IBMTechnology" | |
# System Policy | |
% spctl | |
% sudo spctl --master-disable | |
% sudo spctl --master-enable | |
% ls /System | |
% ls /Library | |
% ls ~/Library | |
% ls /Users | |
% ls /System/Library/CoreServices | |
% ls /Applications | |
% ls ~/Applications | |
% ls /System/Library/CoreServices | |
% ls /System/Library/CoreServices/Finder.app | |
% open /System/Library/CoreServices/Finder.app | |
% say "Rajani" | |
% say -v Bells "dong dong dong" | |
% say -v \? | |
% say -v Good News Truth alone triumphs! | |
% afplay /System/Library/Sounds/Ping.aiff | |
% afplay /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/AnimationFlyToDownloads.aiff | |
% say -v '?' | awk '{print $1}' | while read voice; do printf "using $voice...\n"; say -v $voice "hello, this is me using the $voice voice"; sleep 1; done | |
% ls /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/ | awk '{print $1}' | while read sound; do printf "using $voice...\n"; afplay /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/$sound; sleep 0.5; done | |
% tput bel && sleep 0.33 && tput bel && sleep 0.33 && tput bel && sleep 0.33 && tput bel && sleep 0.33 && tput bel && sleep 0.33 && tput bel && sleep 0.33 && tput bel && sleep 0.33 && tput bel && sleep 0.33 && tput bel && sleep 0.33 && tput bel && sleep 0.33 | |
% echo "\x07" | |
% echo -e "\a" | |
% printf "\a" | |
% tput bel | |
% osascript -e 'beep' | |
% osascript -e 'tell application "System Events" to beep' | |
*************************************************************************************************************************** | |
# Keyboard | |
*************************************************************************************************************************** | |
# Top row of keys to work as standard function keys without holding the Fn key | |
Choose Apple menu > System Settings | |
Click Keyboard in the sidebar | |
Click the Keyboard Shortcuts button on the right | |
Click Function Keys in the sidebar | |
Turn on "Use F1, F2, etc. keys as standard function keys" | |
# Spotlight Search | |
command + space bar | |
# Hidden Files and Folders | |
command + shift + . | |
# Multiple Item Info # Get Summary Info | |
Select item(s) | |
control + command + i | |
# Folder View Options | |
command + J | |
# Or | |
Finder > View > Show View Options | |
# Show Library Folder | |
<command + shift + .> | |
$HOME/Library | |
<command + J> | |
Show Library Folder | |
# Shoe scroll bars | |
# Apple > System Settings... > Appearance | |
# Create folder on a location | |
shift + command + N | |
# Zoom | |
command + option + = | |
command + option + - | |
command + option + 8 | |
# Magnify | |
command + shift + + | |
command + shift + - | |
# Screenshot | |
shit + command + 3 | |
# Screen Capture | |
command + shift + 5 | |
# Screen Capture Selected Portion | |
command + shift + 4 | |
# Screen Capture Entire Screen | |
command + shift + 3 | |
# Go to Folder | |
Finder > Go > Go to Folder | |
# Type | |
/Library/Image Capture/Devices | |
<return> | |
# Go to Enclosing Folder | |
Finder > Go > Enclosing Folder | |
command + up arrow | |
command + down arrow | |
# Copy and Paste | |
command + C | |
command + V | |
# Cut and Paste | |
command + C | |
command + option + V | |
# Backspace | |
fn + delete | |
# Rename File or Folder | |
select file or folder | |
<return> | |
# Terminal Navigation | |
# Navigate thru the line | |
command + option + left arrow | |
command + option + right arrow | |
# Remove previous command | |
command + L | |
# Remove all previous command(s) | |
command + K | |
# Move the cursor to to beginning of the line | |
control + A | |
# Move the cursor to to end of the line | |
control + E | |
# Delete the line | |
control + U | |
# Re-enter the line | |
control + Y | |
# Minimize All | |
command + H + M | |
# Close all windows of an app | |
option + command + W | |
# Force quit app(s) | |
option + command + esc | |
# Vertical Selection: Mouse + option | |
Kilobytes (KB) | |
Megabytes (MB) | |
Gigabytes (GB) | |
Terabytes (TB) | |
Petabytes (PB) | |
Exabytes (EB) | |
Zettabytes (ZB) | |
Yottabytes (YB) | |
# Copy Image To PDF | |
1. Image | |
Open the image using the Preview app | |
Select All | |
<command + C> | |
<command + V> | |
Drag the copied image within the image | |
<command + X> | |
2. PDF | |
Paste the image on the PDF <command + V> | |
Save and close the PDF | |
Open the PDF with the browser | |
Click the printer icon to save as PDF | |
*************************************************************************************************************************** | |
########################################################################################################################### | |
########################################################################################################################### | |
# grep | |
########################################################################################################################### | |
# find filenames with exact string - [Custom] - not case-sensitive | |
$ grep -r -i -w '^[Custom]$' | |
# find filenames with string - [Custom] - case-sensitive | |
$ grep -r -w '^[custom]$' | |
# findstr | |
# find filenames with exact string - [Custom] - not case-sensitive | |
> findstr /m /s /i /c:"[Custom]" * | |
# find filenames with string - [Custom] - case-sensitive | |
> findstr /m /s /c:"[Custom]" * | |
########################################################################################################################### | |
########################################################################################################################### | |
# openssl | |
########################################################################################################################### | |
=========================================================================================================================== | |
% openssl --version | |
% whereis openssl | |
% type openssl | |
% man openss | |
=========================================================================================================================== | |
# tls.sh # % sudo chmod +x ./tls.sh # % ./tls.sh | |
=========================================================================================================================== | |
#!/usr/bin/env zsh | |
export LANG="en_US.UTF-8" | |
export LC_CTYPE="en_US.UTF-8" | |
# Common variables | |
COUNTRY_OR_REGION="AU" | |
STATE_OR_PROVINCE="Some-State" | |
LOCALITY="city" | |
ORGANIZATION_NAME="Internet Widgits Pty Ltd" | |
ORGANIZATIONAL_UNIT_NAME="section" | |
COMMON_NAME_CA="CA.FQDN" | |
COMMON_NAME_SERVER="Server.FQDN" | |
COMMON_NAME_CLIENT="Client.FQDN" | |
EMAIL_ADDRESS_CA="[email protected]" | |
EMAIL_ADDRESS_SERVER="[email protected]" | |
EMAIL_ADDRESS_CLIENT="[email protected]" | |
setopt no_nomatch | |
rm -rf *.crt *.csr *.key *.pem *.srl | |
setopt nomatch | |
# CA # "SHA256" is now the default digest for TS query used by openssl ts | |
openssl req -x509 -days 3650 -newkey rsa:4096 -keyout ca.key -nodes -out ca.crt -subj "/C=${COUNTRY_OR_REGION}/ST=${STATE_OR_PROVINCE}/L=${LOCALITY}/O=${ORGANIZATION_NAME}/OU=${ORGANIZATIONAL_UNIT_NAME}/CN=${COMMON_NAME_CA}/emailAddress=${EMAIL_ADDRESS_CA}" -quiet | |
cat ca.crt ca.key > ca.pem | |
echo Server | |
openssl req -new -newkey rsa:4096 -keyout server.key -out server.csr -nodes -subj "/C=${COUNTRY_OR_REGION}/ST=${STATE_OR_PROVINCE}/L=${LOCALITY}/O=${ORGANIZATION_NAME}/OU=${ORGANIZATIONAL_UNIT_NAME}/CN==${COMMON_NAME_SERVER}/emailAddress=${EMAIL_ADDRESS_SERVER}" -quiet | |
openssl x509 -req -CA ca.crt -CAkey ca.key -in server.csr -out server.crt -days 365 -CAcreateserial | |
cat server.crt ca.crt > server.pem | |
echo Client | |
openssl req -new -newkey rsa:4096 -nodes -keyout client.key -out client.csr -quiet -subj "/C=${COUNTRY_OR_REGION}/ST=${STATE_OR_PROVINCE}/L=${LOCALITY}/O=${ORGANIZATION_NAME}/OU=${ORGANIZATIONAL_UNIT_NAME}/CN=${COMMON_NAME_CLIENT}/emailAddress=${EMAIL_ADDRESS_CLIENT}" | |
openssl x509 -req -CA ca.crt -CAkey ca.key -in client.csr -out client.crt -days 365 -CAcreateserial | |
openssl x509 -text -noout -in ca.crt | |
=========================================================================================================================== | |
########################################################################################################################### | |
########################################################################################################################### | |
# Git Bash # cmd | |
########################################################################################################################### | |
# zip | |
# cd "C:\Users\Aspire\Downloads\wget\Windows binaries of GNU Wget\64-bit" | |
zip "C:\Users\Aspire\Downloads\wget\Windows binaries of GNU Wget\64-bit\wget-1.19.1-win64.zip" "wget-1.19.1-win64\*.*" | |
# unzip | |
unzip archive.zip | |
[ | |
mkdir -p "C:\Wget" | |
] | |
unzip "C:\Users\Aspire\Downloads\wget\Windows binaries of GNU Wget\64-bit\wget-1.19.1-win64.zip" -d "C:\Wget" | |
unzip "C:\Users\Aspire\Downloads\Ruby\Ruby Gems Rails Installation\RubyGems\RubyGems-2.6.12\ZIP\rubygems-2.6.12.zip" -d "C:" | |
unzip "C:\Users\Aspire\Downloads\Maven\Apache-Maven-3.5.0\apache-maven-3.5.0-bin.zip" -d "C:\Program Files\Apache Software Foundation" | |
unzip "C:\Users\Aspire\Downloads\SQLite\Binaries\sqlite-tools-win32-x86-3180000.zip" -d "C:\SQLite" | |
# unzip # only contents without the containing folder | |
unzip -j "C:\Users\Aspire\Downloads\SQLite\Binaries\sqlite-tools-win32-x86-3180000.zip" -d "C:\SQLite" | |
# unzip # rename # recursive | |
% unzip swift-for-wasm-examples-main.zip -d swift-for-wasm-wat-example && mv swift-for-wasm-wat-example/swift-for-wasm-examples-main/* $(pwd)/swift-for-wasm-wat-example | |
# rar [RAR, ZIP, 7-Zip, ACE, ARJ, BZ2, CAB, GZip, ISO, JAR, LZH, TAR, UUE, XZ, Z, 001] | |
control.exe sysdm.cpl,System,3 | |
System Variable | |
Variable name: | |
Path | |
Variable value: | |
;C:\Program Files\WinRAR | |
cd "C:\Users\Aspire\Downloads\wget\Windows binaries of GNU Wget\64-bit" | |
rar a "C:\Users\Aspire\Downloads\wget\Windows binaries of GNU Wget\64-bit\wget-1.19.1-win64.rar" "wget-1.19.1-win64\*.*" | |
# unrar | |
mkdir -p "C:\Wget" | |
unrar e "C:\Users\Aspire\Downloads\wget\Windows binaries of GNU Wget\64-bit\wget-1.19.1-win64.rar" "C:\Wget" | |
# > To $ | |
> start "" "C:\Users\rajanis\AppData\Local\Programs\Git\git-bash.exe" -c "command dotnet --version && /usr/bin/bash" | |
# $ To $ | |
"C:\Users\rajanis\AppData\Local\Programs\Git\git-bash.exe" -c "command dotnet --version && /usr/bin/bash" | |
# > To > | |
> start "Command Prompt: dotnet version" "C:\Windows\System32\cmd.exe" /k "dotnet --version" | |
> start "" "C:\Windows\System32\cmd.exe" /k "dotnet --version" | |
> start "Command Prompt: dotnet version" cmd /k "dotnet --version" | |
> start cmd /k "dotnet --version" | |
# $ To > | |
$ cmd | |
> start cmd /k "dotnet --version" | |
$ sleep 10 | |
> timeout 10 | |
> pause | |
########################################################################################################################### | |
# Kill PID # http://localhost:8080/ | |
$ netstat -ano | findstr :8080 | |
[ | |
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 17740 | |
TCP [::]:8080 [::]:0 LISTENING 17740 | |
] | |
> netstat -ano | findstr :8080 | |
[ | |
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 17740 | |
TCP [::]:8080 [::]:0 LISTENING 17740 | |
] | |
$ taskkill -PID 17740 -F | |
# SUCCESS: The process with PID 17740 has been terminated. | |
> taskkill /PID 17740 /F | |
# SUCCESS: The process with PID 17740 has been terminated. | |
# ps | |
$ ps ef | |
[ | |
PID PPID PGID WINPID TTY UID STIME COMMAND | |
] | |
$ ps -ef | |
[ | |
UID PID PPID TTY STIME COMMAND | |
] | |
$ ps aux | |
[ | |
PID PPID PGID WINPID TTY UID STIME COMMAND | |
] | |
$ ps | |
[ | |
PID PPID PGID WINPID TTY UID STIME COMMAND | |
] | |
$ tasklist | |
> tasklist | |
[ | |
Image Name PID Session Name Session# Mem Usage | |
] | |
########################################################################################################################### | |
# CertUtil | |
########################################################################################################################### | |
[ | |
https://www.oracle.com/java/technologies/javase-jre8-downloads.html | |
https://www.oracle.com/java/technologies/javase-jre8-downloads.html#license-lightbox | |
https://www.oracle.com/webfolder/s/digest/8u261checksum.html | |
jre-8u261-windows-x64.tar.gz | |
sha256: edd4a4568582ff50fb9d575169f5a3ceab26e80f6ecb7b04d133fff061881a8f | |
md5: 0c4f43e28ce3d0afbe9c7d9d693b3883 | |
] | |
$ CertUtil -hashfile "C:\Users\rajanis\Downloads\Java\JRE\jre-8u261-windows-x64.tar.gz" MD5 | |
MD5 hash of C:\Users\rajanis\Downloads\Java\JRE\jre-8u261-windows-x64.tar.gz: | |
0c4f43e28ce3d0afbe9c7d9d693b3883 | |
CertUtil: -hashfile command completed successfully. | |
$ CertUtil -hashfile "C:\Users\rajanis\Downloads\Java\JRE\jre-8u261-windows-x64.tar.gz" sha256 | |
SHA256 hash of C:\Users\rajanis\Downloads\Java\JRE\jre-8u261-windows-x64.tar.gz: | |
edd4a4568582ff50fb9d575169f5a3ceab26e80f6ecb7b04d133fff061881a8f | |
CertUtil: -hashfile command completed successfully. | |
> CertUtil -hashfile "C:\Users\rajanis\Downloads\Java\JRE\jre-8u261-windows-x64.tar.gz" MD5 | |
MD5 hash of C:\Users\rajanis\Downloads\Java\JRE\jre-8u261-windows-x64.tar.gz: | |
0c4f43e28ce3d0afbe9c7d9d693b3883 | |
CertUtil: -hashfile command completed successfully. | |
> CertUtil -hashfile "C:\Users\rajanis\Downloads\Java\JRE\jre-8u261-windows-x64.tar.gz" sha256 | |
SHA256 hash of C:\Users\rajanis\Downloads\Java\JRE\jre-8u261-windows-x64.tar.gz: | |
edd4a4568582ff50fb9d575169f5a3ceab26e80f6ecb7b04d133fff061881a8f | |
CertUtil: -hashfile command completed successfully. | |
########################################################################################################################### | |
# PowerShell | |
########################################################################################################################### | |
[ | |
% pwsh | |
$ winpty powershell | |
> powershell | |
] | |
PS> $host | |
PS> $host.Version | |
PS> $PSVersionTable | |
PS> Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
# PS> cd | |
PS> dir | Unblock-File | |
PS> dir –Recurse | Unblock-File | |
PS> dir "D:\Tech2021\JavaScript" –Recurse | Unblock-File | |
PS> Get-ChildItem -Path "D:\Tech2021\JavaScript" -Recurse | Unblock-File | |
PS> gci -Path "D:\Tech2021\JavaScript" -Recurse | Unblock-File | |
PS> exit | |
PS> Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh') | |
# Or | |
PS> iwr -useb get.scoop.sh | iex | |
# NB | |
# PS> Set-ExecutionPolicy RemoteSigned -scope CurrentUser | |
PS> exit | |
########################################################################################################################### | |
########################################################################################################################### | |
# Windows # Run # cmd | |
########################################################################################################################### | |
# Console Windows Properties | |
Options | |
Buffer Size 999 | |
Number of Buffers 999 | |
Edit Options | |
[Checked] QuickEdit Mode | |
[Checked] Insert Mode | |
# Font | |
16 | |
# Layout | |
Screen Buffer Size | |
Width 9999 ([Uncheck] Wrap text output or resize) | |
Height 9999 | |
Window Size | |
Width 160 | |
Height 30 | |
[Checked] Let system position window | |
----------------------------------------------------------------- | |
Control panel tool Command | |
----------------------------------------------------------------- | |
Accessibility Options control access.cpl | |
Add New Hardware control sysdm.cpl add new hardware | |
Add/Remove Programs control appwiz.cpl | |
Date/Time Properties control timedate.cpl | |
Display Properties control desk.cpl | |
FindFast control findfast.cpl | |
Fonts Folder control fonts | |
Internet Properties control inetcpl.cpl | |
Joystick Properties control joy.cpl | |
Keyboard Properties control main.cpl keyboard | |
Microsoft Exchange control mlcfg32.cpl | |
(or Windows Messaging) | |
Microsoft Mail Post Office control wgpocpl.cpl | |
Modem Properties control modem.cpl | |
Mouse Properties control main.cpl | |
Multimedia Properties control mmsys.cpl | |
Network Properties control netcpl.cpl | |
NOTE: In Windows NT 4.0, Network | |
properties is Ncpa.cpl, not Netcpl.cpl | |
Password Properties control password.cpl | |
PC Card control main.cpl pc card (PCMCIA) | |
Power Management (Windows 95) control main.cpl power | |
Power Management (Windows 98) control powercfg.cpl | |
Printers Folder control printers | |
Regional Settings control intl.cpl | |
Scanners and Cameras control sticpl.cpl | |
Sound Properties control mmsys.cpl sounds | |
System Properties control sysdm.cpl | |
----------------------------------------------------------------- | |
# Command Prompt | |
cmd | |
# About Windows | |
winver | |
# Local Disk | |
\ | |
# Current User Folde | |
. | |
# Users Folder | |
.. | |
# Ease of Access Center | |
utilman | |
# Or | |
control access.cpl | |
# Add Hardware | |
hdwwiz | |
# Get Programs | |
control appwiz.cpl,,1 | |
# Windows Features | |
control appwiz.cpl,,2 | |
# Set Program Access and Computer Defaults | |
control appwiz.cpl,,3 | |
# User Accounts | |
netplwiz | |
# Authorization Manager | |
azman.msc | |
# Windows Update | |
control wuaucpl.cpl | |
# Bluetooth Transfer | |
fsquirt | |
# certmgr [Certificates Current User] | |
certmgr.msc | |
# Character Map | |
charmap | |
# Check Disk Utility (cmd) | |
chkdsk | |
# ClearType Text Tuner | |
cttune | |
# Color Management | |
colorcpl | |
# Component Services | |
dcomcnfg | |
or | |
comexp.msc | |
# Computer Management | |
compmgmt.msc | |
# Control Panel | |
control | |
# Stored User Names and Pasworss | |
credwiz | |
# Performance Actions | |
SystemPropertiesDataExecutionPrevention | |
# Device Manager | |
devmgmt.msc | |
# Add a device | |
DevicePairingWizard | |
# Digitizer Calibration Tool | |
tabcal | |
# DirectX Diagnostic Troubleshooter | |
dxdiag | |
# Disk Cleanup | |
cleanmgr | |
# Optimize Drives | |
dfrgui | |
# Microsoft Drive Optimizer (cmd) | |
defrag | |
# Disk Management | |
diskmgmt.msc | |
# DiskPart (cmd) | |
diskpart | |
# Display Color Calibration | |
dccw | |
# Display | |
dpiscaling | |
# Personalization | |
control desktop | |
# Color and Appearance | |
control color | |
# Driver Verifier Manager | |
verifier | |
# Windows Media Player | |
dvdplay | |
# Environment Variables | |
rundll32 sysdm.cpl,EditEnvironmentVariables | |
# System Properties -> Advanced -> Environment Variables | |
control sysdm.cpl,System,3 | |
# Encrypting File System (Only for Supported Windows Version) | |
Rekeywiz | |
# Event Viewer | |
eventvwr.msc | |
# File Signature Verification | |
sigverif | |
# Windows Easy Transfer | |
%systemroot%\system32\migwiz\migwiz | |
# Windows Firewall | |
firewall.cpl | |
# Windows Firewall with Advanced Security | |
wf.msc | |
# Folders Options | |
control folders | |
# Arial (OpenType) | |
fontview arial.ttf | |
# IP Configuration (cmd) | |
ipconfig | |
# Microsoft iSCSI | |
iscsicpl | |
# Keyboard Properties | |
control keyboard | |
# Install or uninstall display languages | |
lpksetup | |
# lusrmgr [Users and Groups (Local)] | |
lusrmgr.msc | |
# Microsoft Windows Malicious Software Removal Tool | |
mrt | |
# Console [Console Root] | |
mmc | |
# Microsoft Support Diagnostic Tool | |
msdt | |
# Mouse Properties | |
control mouse | |
or | |
main.cpl | |
# Network Connections | |
control netconnections | |
or | |
ncpa.cpl | |
# Project to a Connected Screen | |
displayswitch | |
# ODBC Data Source Administrator (32-bit) | |
odbcad32 | |
# ODBCConf Usage | |
odbcconf | |
# On Screen Keyboard | |
osk | |
# Forgotten Password Wizard | |
rundll32 keymgr.dll,PRShowSaveWizardExW | |
# Pen and Touch | |
tabletpc.cpl | |
# Performance Monitor | |
perfmon.msc | |
# Phone and Modem | |
telephon.cpl | |
# Phone Dialer | |
dialer | |
# Power Options | |
powercfg.cpl | |
# Power Options (cmd) | |
powercfg /? | |
# Steps Recorder | |
psr | |
# Set Program Access and Computer Defaults | |
computerdefaults | |
# Printer User Interface | |
printui | |
# Private Character Editor | |
eudcedit | |
# Registry Editor | |
regedit | |
# Windows Remote Assistance | |
msra | |
# Resource Monitor | |
resmon | |
# Task Scheduler | |
control schedtasks | |
# Action Center | |
wscui.cpl | |
# Services | |
services.msc | |
# Create A Shared Folder Wizard | |
shrpubw | |
# Shared Folders | |
fsmgmt.msc | |
# Enter a product key | |
slui | |
# Sound Recorder | |
soundrecorder | |
# Sound Volume | |
sndvol | |
# Sync Center | |
mobsync | |
# System Configuration | |
msconfig | |
# Microsoft Windows Resource Checker | |
sfc | |
# System Information | |
msinfo32 | |
# System Properties | |
sysdm.cpl SystemProperties | |
# Or | |
sysdm.cpl DisplaySYSDMCPL | |
# Performance Optiopns | |
SystemPropertiesPerformance | |
# System Properties Hardware | |
SystemPropertiesHardware | |
# System Properties Advanced | |
SystemPropertiesAdvanced | |
# Task Manager | |
taskmgr | |
# Task Scheduler | |
taskschd.msc | |
# Manage the TPM security hardware | |
tpmInit | |
# User Accounts | |
control userpasswords2 | |
# User Account Control Settings | |
UserAccountControlSettings | |
# User Profiles | |
rundll32 sysdm.cpl,EditUserProfiles | |
# Windows Disc Image Burning Tool | |
[ | |
isoburn <path>\file.iso | |
] | |
# Windows Explorer | |
explorer | |
# Windows Features | |
optionalfeatures | |
# Scanner | |
wiaacmgr | |
# Windows Magnifier | |
magnify | |
# wmimgmt [Control Root\WMI Control (Local)]] | |
wmimgmt.msc | |
# Windows Memory Diagnostic | |
mdsched | |
# Windows Mobility Center | |
mblctr | |
# Windows PowerShell | |
powershell | |
# Windows PowerShell ISE | |
powershell_ise | |
# Securing the Windows Account Database | |
syskey | |
# Windows Update | |
wuapp | |
# Windows Update Standalone Installer | |
wusa | |
# Snipping Tool | |
snippingtool | |
# Calculator | |
calc | |
# Paint | |
mspaint | |
# Word | |
winword | |
# Excel | |
excel | |
# Powerpoint | |
powerpnt | |
# Access | |
msaccess | |
# Remote Desktop Connection | |
mstsc | |
# System Restore | |
rstrui | |
# System Info | |
systeminfo | |
# Shut down | |
shutdown | |
# Or | |
shutdown -s | |
# Restart | |
shutdown -r | |
# Logoff | |
shutdown -l | |
# Number of seconds to wait till | |
shutdown <-s/-r> -t <number> | |
# Dialog box to select [Restart/Shutdown/Annotate Unexpected Shutdown] from dropdown box or Cancel | |
shutdown -i | |
# Abort any previous shutdown command | |
shutdown -a | |
# Hibernate | |
shutdown -h | |
# Force the selected action | |
shutdown <-s/-r-l> -f | |
%APPDATA%\Microsoft\Windows\ | |
C:\Users\Rajani\AppData\Roaming\Microsoft\Windows | |
%Temp% | |
C:\Users\Rajani\AppData\Local\Temp | |
%systemroot%\System32\ | |
C:\WINDOWS\System32 | |
########################################################################################################################### | |
// Credits | |
/* | |
https://zsh.sourceforge.io/ | |
https://gnu.org/software/bash/ | |
https://microsoft.com/powershell/ | |
https://microsoft.com/windows-server/ | |
https://curl.se/ | |
https://gnu.org/software/wget/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment