nhaliday + terminal   59

Homebrew: List only installed top level formulas - Stack Overflow
Use brew leaves: show installed formulae that are not dependencies of another installed formula.
q-n-a  stackex  howto  yak-shaving  programming  osx  terminal  network-structure  graphs  trivia  tip-of-tongue  workflow  build-packaging 
november 2017 by nhaliday
awk - Assigning system command's output to variable - Stack Overflow
awk 'BEGIN {"date" | getline mydate; close("date"); print "returns", mydate}'
q-n-a  stackex  howto  yak-shaving  terminal  programming  gotchas 
november 2017 by nhaliday
man page - Wikipedia
NAME
The name of the command or function, followed by a one-line description of what it does.
SYNOPSIS
In the case of a command, a formal description of how to run it and what command line options it takes. For program functions, a list of the parameters the function takes and which header file contains its definition.
DESCRIPTION
A textual description of the functioning of the command or function.
EXAMPLES
Some examples of common usage.
SEE ALSO
A list of related commands or functions.
explanation  programming  engineering  documentation  howto  terminal  unix  wiki  reference  cheatsheet  trivia  info-foraging 
september 2017 by nhaliday
bash - Queue up commands while one command is being executed - Unix & Linux Stack Exchange
Press Ctrl+Z and immediately run bg. This causes the current command to keep running in the background. Then you can use fg && otherCommand to schedule otherCommand after the current one.

To make this easier, I've configured Ctrl+Z in my shell to run bg when I press it on an empty command line. See In zsh, how can I more quickly disown the foreground process? and How do you send command line apps directly to the background? ; I haven't checked if modern versions of bash make it easy to do the same.
q-n-a  stackex  unix  terminal  howto  workflow  short-circuit  tip-of-tongue 
september 2017 by nhaliday
How to extract files to another directory using 'tar' command? - Ask Ubuntu
Combining the previous answers and comments:

To simply extract the contents and create target directory if it is missing:

mkdir -p /target/directory && tar xf archive.tar -C /target/directory
To extract and also remove the root(first level) directory in the zip

mkdir -p /target/directory && tar xf archive.tar -C /target/directory --strip-components=1
q-n-a  stackex  howto  terminal  unix  yak-shaving  workflow  intricacy 
september 2017 by nhaliday
bash - How to find/replace and increment a matched number with sed/awk? - Stack Overflow
/e allows you to pass matched part to external command, and do substitution with the execution result. Gnu sed only.
why you need to get first and last part of lines: https://unix.stackexchange.com/questions/180783/sed-e-and-g-flags-not-working-together
That is a bit tortuously written. What it means is that, after the completion of a s/// command for this line, if there was a change, the (new) line is executed as a command and its output used as the replacement for this line.

example of what I had to do to get this to work w/ embedded quotes:
gsed -E 's/^\("(.*)", ([0-9]+)(.*)/echo "(\\\\"\1\\\\", $((\2+54))\3"/e'
maps ("foo", 3... -> ("foo", 57..
q-n-a  stackex  programming  howto  terminal  unix  yak-shaving  multi  gotchas 
september 2017 by nhaliday
linux - How do I replace the last occurrence of a character in a string using sed? - Unix & Linux Stack Exchange
You can do it with single command:

sed 's/\(.*\)-/\1 /'
The point is that sed is very greedy, so matches as many characters before - as possible, including others -.
q-n-a  stackex  howto  workflow  yak-shaving  terminal  unix  programming 
august 2017 by nhaliday
unix - How to split a delimited string into an array in awk? - Stack Overflow
To split a string to an array in awk we use the function split():

awk '{split($0, a, ":")}'
# ^^ ^ ^^^
# | | |
# string | delimiter
# |
# array to store the pieces
If no separator is given, it uses the FS, which defaults to the space:

$ awk '{split($0, a); print a[2]}' <<< "a:b c:d e"
c:d
q-n-a  stackex  programming  howto  yak-shaving  terminal  unix  workflow 
august 2017 by nhaliday
Where are my iBooks stored in macOS Sierra? - Ask Different
example for finding mentions of a string:
<go to that direction>
pt -c 'foobar' | awk -F: 'function dir(path) {sub("/.*", "", path); return path} {a[dir($1)]+=$2} END{for (k in a) {print a[k], k}}' | sort -nr
now wrapped up in a script: ~/bin/ibooks_mentions
q-n-a  stackex  workflow  yak-shaving  integration-extension  studying  sleuthin  info-foraging  osx  desktop  multi  terminal  unix  howto 
august 2017 by nhaliday
What is the best way to parse command-line arguments with Python? - Quora
- Anders Kaseorg

Use the standard optparse library.

It’s important to uphold your users’ expectation that your utility will parse arguments in the same way as every other UNIX utility. If you roll your own parsing code, you’ll almost certainly break that expectation in obvious or subtle ways.

Although the documentation claims that optparse has been deprecated in favor of argparse, which supports more features like optional option arguments and configurable prefix characters, I can’t recommend argparse until it’s been fixed to parse required option arguments in the standard UNIX way. Currently, argparse uses an unexpected heuristic which may lead to subtle bugs in other scripts that call your program.

consider also click (which uses the optparse behavior)
q-n-a  qra  oly  best-practices  programming  terminal  unix  python  libraries  protocol  gotchas  howto  pls  yak-shaving  integration-extension 
august 2017 by nhaliday
Working effectively with iTerm2 - teohm.dev
Cmd-K does what I was trying to do using Ctrl-L during that addepar interview
tools  tutorial  productivity  workflow  howto  techtariat  terminal  osx  software 
march 2016 by nhaliday

bundles : techie

related tags

app  bangbang  best-practices  blog  books  build-packaging  c(pp)  cheatsheet  code-dive  commentary  comparison  database  dataviz  debugging  desktop  devtools  discussion  distributed  documentation  duplication  dynamic  editors  emacs  engineering  explanation  generalization  gif  git  golang  gotchas  graphs  guide  hn  howto  info-foraging  init  integration-extension  internet  intricacy  iteration-recursion  libraries  links  linux  list  machine-learning  measure  metrics  minimalism  multi  network-structure  networking  nibble  oly  oss  osx  paste  performance  pinboard  plan9  pls  plt  pragmatic  productivity  programming  project  protocol  python  q-n-a  qra  random  recommendations  recording  reddit  reference  repo  search  short-circuit  sleuthin  social  software  stackex  stream  strings  studying  systems  techtariat  terminal  tip-of-tongue  todo  tools  trivia  tutorial  ui  unit  unix  ux  vcs  video  virtualization  visualization  visuo  volo-avolo  web  wiki  workflow  working-stiff  worrydream  yak-shaving 

Copy this bookmark:



description:


tags: