Table of contents
Gists
Sync Chrome Bookmarks
used to sync a bookmark file to a repo to update on both Mac and windows using bash and PowerShell when an account cannot sync due to admin
restrictions
Tar File
Compress an entire directory
/home/vivek/data/
tar -czvf file.tar.gz /home/vivek/data/
To compress multiple directories and files, execute:
tar -czvf file.tar.gz /home/vivek/data/ /home/vivek/pics/ /home/vivek/.accounting.db
One can use
bzip2
compression instead ofgzip
by passing the-j
option to thetar
command:
tar -cjvf file.tar.bz2 /home/vivek/data/
Options
Create a new archive
- c
Verbose output
- v
Use archive file
- f
Filter the archive through gzipfile.tar.gz
- z
Filter the archive through bzip2
- j
Un Tar
tar xvf <.tar file>
tar xzvf <.tar.gz file>
tar xjvf <.tar.bz2 file>
ZIP folder and add a password
zip -er last_resort.zip attachments;
Find
find and remove files
for st in $(mdfind -name ultdata); do rm -rf "$st"; done
Find and Delete Empty Directories
$ find . -type d -empty -exec rmdir -v {} +
find and kill by pid
pkill -f '.*GradleDaemon.*'
kill by port
npx kill-port 18090
Add Table of Contents to mark down doc with pandoc
set file name
fileMD=CLI_Grailsw.md;
run
pandoc -s --toc $fileMD -o output.md; rm -f $fileMD; mv output.md ./$fileMD;
UseCase Examples
CAT
Show Line Endings
cat -e file.txt
Display Line Numbers
cat -n file.txt
This command is equivalent to the ‘nl file’ command.
nl file.txt
Display Tab Characters
cat -T file.txt
Reverse a File using tac
tac file.txt file2.txt
Remove Blank Lines
cat -s file.txt
Create Here Document
A here document (here doc) is a way to interactively input multiple lines of text into a command or program.
In the case of the cat command, you can use a here doc to provide the content that cat
should display.
Here’s an example using a here doc with the cat command:
cat << EOF
> type text
> more text
> and more text
> more more more text
> EOF
In this example, the « EOF notation indicates the start of the here doc, and the lines following it are treated as input until the EOF delimiter is
encountered.
The cat command will display the
content of the here doc, which in this case consists of three lines.
Mac
get local ip
osascript -e "IPv4 address of (system info)"
ifconfig | grep "inet "
convert file/image to base64
base64 -i ./post_u_north_gate.jpg | pbcopy
cat ./post_u_north_gate.jpg | openssl base64 | tr -d '\n' | pbcopy
./post_u_north_gate.jpg | openssl base64 | tr -d '\n' | pbcopy