How to assign the output of a command to a Makefile variable
Use the Make shell builtin like in MY_VAR=$(shell echo whatever) me@Zack:~$make MY_VAR IS whatever me@Zack:~$ cat Makefile MY_VAR := $(shell echo whatever) all: @echo MY_VAR IS $(MY_VAR)
Use the Make shell builtin like in MY_VAR=$(shell echo whatever) me@Zack:~$make MY_VAR IS whatever me@Zack:~$ cat Makefile MY_VAR := $(shell echo whatever) all: @echo MY_VAR IS $(MY_VAR)
Typically, your help output should include: Description of what the app does Usage syntax, which: Uses [options] to indicate where the options go arg_name for a required, singular arg [arg_name] for an optional, singular arg arg_name… for a required arg of which there can be many (this is rare) [arg_name…] for an arg for which … Read more
As pointed by B. Rhodes, nc (netcat) will do the job. A more compact way to use it: nc -z <host> <port> That way nc will only check if the port is open, exiting with 0 on success, 1 on failure. For a quick interactive check (with a 5 seconds timeout): nc -z -v -w5 … Read more
For Bash scripts, the most direct and performant approach is: if compgen -G “${PROJECT_DIR}/*.png” > /dev/null; then echo “pattern exists!” fi This will work very speedily even in directories with millions of files and does not involve a new subshell. Source The simplest should be to rely on ls return value (it returns non-zero when … Read more
The xargs command takes white space characters (tabs, spaces, new lines) as delimiters. You can narrow it down only for the new line characters (‘\n’) with -d option like this: ls *.mp3 | xargs -d ‘\n’ mplayer It works only with GNU xargs. For MacOS: ls *.mp3 | tr \\n \\0 | xargs -0 mplayer … Read more
You can write a small shell script that launches tmux with the required programs. I have the following in a shell script that I call dev-tmux. A dev environment: #!/bin/sh tmux new-session -d ‘vim’ tmux split-window -v ‘ipython’ tmux split-window -h tmux new-window ‘mutt’ tmux -2 attach-session -d So everytime I want to launch my … Read more
Use : ‘ to open and ‘ to close. For example: : ‘ This is a very neat comment in bash ‘
>> /dev/null redirects standard output (stdout) to /dev/null, which discards it. (The >> seems sort of superfluous, since >> means append while > means truncate and write, and either appending to or writing to /dev/null has the same net effect. I usually just use > for that reason.) 2>&1 redirects standard error (2) to standard … Read more
Use -o, which means “or”: find Documents \( -name “*.py” -o -name “*.html” \) You’d need to build that command line programmatically, which isn’t that easy. Are you using bash (or Cygwin on Windows)? If you are, you should be able to do this: ls **/*.py **/*.html which might be easier to build programmatically.
With n being the line number: ng: Jump to line number n. Default is the start of the file. nG: Jump to line number n. Default is the end of the file. So to go to line number 320123, you would type 320123g. Copy-pasted straight from Wikipedia.