November 27, 2022

*NIX Command Line Foo

Category: Uncategorized,UNIX Scripting — Raffael Marty @ 11:28 am

Well, not one of my normal blog posts, but I hope some of you geeks out there will find this useful anyways. I will definitely use this post as a reference frequently.

I have been using various flavors of UNIX and their command lines from ksh to bash and zsh for over 25 years and there is always something new to learn to make me faster at the jobs I am doing. One tool that I keep using (despite my growing command of Excel), is VIM coupled with UNIX command line tools. It saves me hours and hours of work all the time.

Well, here are some new things I learned and want to remember from the Well, here are some new things I learned and want to remember from the art of command line github repo:

  • CTRL-W on the command line deletes the last word
  • pgrep to search for processes rather than doing the longer version with awk
  • lsof -iTCP -sTCP:LISTEN -P -n processes listening on TCP ports
  • Diff two json files: diff <(jq --sort-keys . < file1.json) <(jq --sort-keys . < file2.json) | colordiff | less -R
  • I totally forgot about csvkitbrew install csvkit
    • in2csv file1.xls > file1.csv
    • csvstat data.csv
    • csvsql --query "select name from data where age > 30" data.csv > old.csv

I just found some additional command son OSX that I wish I had known earlier:

  • ditto copies one or more source files or directories to a destination directory. If the destination directory does not exist it will be created before the first source is copied. If the destination directory already exists then the source directories are merged with the previous contents of the destination.
  • pbcopy past data from command line into the clipboard
  • qlmanage quick view from the command line

This is a great repo as well for great OSX commands.

No Comments »

No comments yet.

RSS feed for comments on this post. | TrackBack URI

Leave a comment

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> .