Unix Tips


These tips are the result of online search to solve problems arising from working on real projects at work.


Download CSV File using Curl

curl -H "Accept:text/csv" http://localhost:3000/report_jobs/9

This will invoke the format.csv block to download the csv file.

Using curl to Post xml Document

curl -X POST -d '<run><log encoding="hexBinary">4142430A</log><result>0</result><duration>2000</duration></run>' http://www.example.com/rest/api 

Vi Editor Tips

Go to a given line in vi


goes to line 15

Move to the end of the file in vi

$ then A

Delete in vi


This deletes from the current position to the end of the line in vi editor

Miscellaneous Tips

Check how long a process has been running

$ps -p 64622 -o etime=

PID is 64622


How to search for last occurrence of a string in a file

grep 'string to search' log-file-name.log | tail -1

Count the Number of Occurrences of a Given String

grep -c 'string to search' file-name.log 

List Processes Running with the Ports on Mac OS

lsof -i | grep LISTEN

Find Files

find . -name '*.sql' -print

Related Articles

Ace the Technical Interview

  • Easily find the gaps in your knowledge
  • Get customized lessons based on where you are
  • Take consistent action everyday
  • Builtin accountability to keep you on track
  • You will solve bigger problems over time
  • Get the job of your dreams

Take the 30 Day Coding Skills Challenge

Gain confidence to attend the interview

No spam ever. Unsubscribe anytime.