Skip to content

Instantly share code, notes, and snippets.

@estysdesu
estysdesu / whereYaAt.sh
Last active March 25, 2020 20:37
[Shell: Locating Files] #find #locate #sh
##### `find` (TREE SEARCH; SLOWER) #####
# https://math2001.github.io/post/bashs-find-command/
##### `locate` (DB SEARCH; FASTER; POSSIBLY WRONG) #####
# https://www.howtoforge.com/linux-locate-command/
@estysdesu
estysdesu / makefile
Last active July 31, 2019 11:49
[Make: variables and assignment] #gnu #make #makefile
##### make/shell VARIABLES #####
# $(<var>): reference make variable
# ${<var>}: reference environment variable
x = `pwd`; echo $(x)
y = ${PATH}
##### `=`/`:=`/`?=`/`+=` (VARIABLE ASSIGNMENT) #####
# https://stackoverflow.com/questions/448910/what-is-the-difference-between-the-gnu-makefile-variable-assignments-a
# `=`: evaluated when used, not declared (lazy set); setting of a variable where values within it are recursively expanded when the variable is used
# `:=`: evaluated immediately (immediate set); setting of a variable with simple expansion of the values inside
@estysdesu
estysdesu / background.sh
Last active March 25, 2020 20:31
[Shell: Foreground <--> Background] #sh #fg #bg
# https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session -- nohup, disown
##### `&` (BACKGROUND) #####
# foreground task (blocking)
ping localhost > /dev/null
# background task (non-blocking)
ping localhost > /dev/null & # returns [<jobNo>] <PID>
##### `jobs` (SHOW RUNNING BG JOBS) #####
ping localhost > /dev/null & # --> [1] 107
@estysdesu
estysdesu / logs.md
Created July 28, 2019 09:40
[Logging: file locations] #log #mac # osx #macos

Log File Locations (for user installed applications)

macOS

  • $HOME/Libarary/Application Support/<appName>/logs

Windows

@estysdesu
estysdesu / data.md
Last active July 28, 2019 09:42
[Linux: system data locations]

System Data Locations

Processes and Hardware Info

  • /proc and /sys are pseudo filesystems; they're kept in memory by the computer the whole time
  • /proc contains info abt active processes, system hardware, and kernel configuration
  • /dev is how to access hardware devices
  • /sys contains info abt the hardware devices in /dev

Viewing Running Processes

  • pstree: shows parent/child processes' relationship
@estysdesu
estysdesu / hardware.sh
Last active July 21, 2019 11:47
[Shell: hardware info] #memory #architecture #cpu
##### CPU #####
cat /proc/cpuinfo
##### arch (ARCHITECTURE) #####
# arch may denote the mode your computer is running in, but not necessarily is an indicator of what it support
# https://superuser.com/questions/23214/why-does-my-mac-os-x-10-6-kernel-run-in-32-bit-mode
arch # i386/x86 denotes 32-bit, x86_64 denotes 64-bit, a few other variations
##### lscpu (ARCHITECTURE) #####
lscpu #x86[_64]
@estysdesu
estysdesu / math.sh
Last active July 21, 2019 09:03
[Shell: math constructs] #bash #math #double #parenthesis #(( #sh #seq #bc #range
##### `((` (DOUBLE PARENTHESIS) #####
# Bash only
# arithmetic expansion
(( a=25 )) # C style setting
(( a++ )) && echo $a # a == 26; same as `(( ++a ))`
(( a-- )) && echo $a # a == 25; same as `(( --a ))`
# arithmetic evaluation
(( t = a<45?7:11 )) # t == 7; if a < 45, then t = 7, else t = 11
# https://www.tldp.org/LDP/abs/html/loops1.html#FORLOOPC
LIMIT=10
@estysdesu
estysdesu / mov.sh
Last active July 21, 2019 06:00
[Shell: file movement] #cp #mv #rm #ln #sh
##### ln (SYMLINKS) #####
# -n: no dereference (prevents recursion of directories by stopping link following)
# -f: force if already exists by unlinking first
# -s: symbolic
# -d/-F: directory
ln -sf <path/to/source/file> <path/to/dest/file>
ln -sFn <path/to/source/dir> <path/to/dest/dir>
@estysdesu
estysdesu / win.ps1
Last active July 21, 2019 05:52
[WSL: X-Server for UI] #wsl #x #server #sh #posh
##### WINDOWS #####
$uri = 'https://sourceforge.net/projects/xming/files/Xming/6.9.0.31/Xming-6-9-0-31-setup.exe/download'
curl -L $uri > Xming-setup.exe
@estysdesu
estysdesu / ppPath.sh
Created July 21, 2019 05:11
[Shell: pretty pring PATH] #sh #path #pprint #pretty #print
#!/usr/bin/env bash
# https://github.com/estysdesu/dotFiles/blob/master/bash/.bash_profile
alias ppPATH="echo $PATH | tr -s ':' '\n'" # each path member gets it's own line