software:unixtools [PaleoEarthLabs wiki]

PaleoEarthLabs wiki

One bucket of limited wisdom

Site Tools


software:unixtools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
software:unixtools [2019/12/18 11:13]
christian [Image manipulation]
software:unixtools [2020/06/27 22:29] (current)
chwikad [Unison]
Line 2: Line 2:
  
 A collection of quick-and-dirty tricks to do things with the standard command line tools in *Nix and cygwin. I am copying stuff here as I use these snippets regularly so this is a central repo for the ageing brain. A collection of quick-and-dirty tricks to do things with the standard command line tools in *Nix and cygwin. I am copying stuff here as I use these snippets regularly so this is a central repo for the ageing brain.
 +
 +===== Bash =====
 +
 +Loop through a list of data, providing special cases depending on input data.
 +
 +<code bash>
 +inData=( data1 data2 data3 )  # This generates an iterable list of items
 +for theData in  ${inData[*]}; do
 +    case "$theData" in
 + "data1"
 +   inGrid="$grid1"
 +          cpt=
 + ;;
 + "data2"
 +          inGrid="$grid2"
 +          cpt=
 + ;;
 +    esac
 +done
 +</code>
 +
 +  * Using ''set -x'' prints a ''+'' before each executed command in a bash script via [[https://www.peterbe.com/plog/set-ex]]
 +
 +
  
 ===== AWK ===== ===== AWK =====
Line 33: Line 57:
  
 awk -v a="$var1" -v b="$var2" 'BEGIN {print a,b}' awk -v a="$var1" -v b="$var2" 'BEGIN {print a,b}'
 +</code>
  
 +
 +Convert a GMT file into a csv file which can be processed by ''ogr2ogr'', meanwhile adding some attributes.
 +
 +<code awk>
 +awk -v url="${someurl}" -v r="$another" -v au="$au" 'BEGIN{OFS=","} {
 +  if (/^>/) split($5,a,"-") split($NF,b,"=")
 +  else 
 +  printf("%03d,%s,%s,%s,%s/%s_MyOutput_%03d.png,%s\n", a[3], $1, $2, b[2], url, r, a[3], au )}' ${v}/${v}_somedata.dat >> tmp.csv
 </code> </code>
  
Line 72: Line 105:
  
 </code> </code>
 +
 +
 +===== Reset the shell =====
 +
 +At some stage I accidentally used ``curl`` instead of ``wget`` resulting in a bunch of wild binary stuff being passed on to the shell, resetting the bash configuration. [[https://unix.stackexchange.com/questions/302548/hash-symbols-turned-into-pound-symbols-%C2%A3-after-catting-a-binary|Turns out that I am fortunately not alone]] and one can [[http://man7.org/linux/man-pages/man4/console_codes.4.html|reset the console codes]] to their defaults using:
 +
 +    reset
 +    
 +===== Unison =====
 +
 +[[https://www.cis.upenn.edu/~bcpierce/unison/|Unison]] is a fantastic tool to synchronise directories on multiple computers, like a desktop or server and a laptop. I have been using Unison now for a couple of years after using 
 +
 +It seems that some of the Apple Security Updates change/alter the machine settings in places such as ''/etc/ssh/ssh_config''. This then results in unison (which is run over ''ssh'') then to complain that the path cannot be found. The remedy is make sure that in ''/etc/ssh/sshd_config'' (note the **d**!) the following parameter is set to: ''PermitUserEnvironment yes''
 +
 +
 +
  
  
Line 78: Line 127:
  
  
-{{tag> Unix awk command_line Quick_and_dirty SEGY magick imageprocessing}}+{{tag> Unix awk command_line Quick_and_dirty SEGY magick imageprocessing reset}}
software/unixtools.1576664003.txt.gz · Last modified: 2019/12/18 11:13 by christian