How to Use Awk to Remove the First Line of a File

Awk is a versatile pattern scanning application, installed by default on most Linux distributions. If you have Ubuntu, Debian, or openSUSE, it's already installed. You can use Awk to easily remove the first line or row of a text file. To do so, just run the following one-liner command. Make sure to specify the source file, and the file you want the processed data to go to:

awk '{if(NR>1)print}' source_file.txt > processed_file.txt


How to Remove Commas Inside of Quotes From a CSV or Text File on Linux with Awk

Let's say you have a CSV file that you would like to open in Excel or LibreOffice Calc to analzye. You find out the formatting is broken because there is a column that has quoted text with a comma in it:

Name, Country, City

Jason, US, Memphis

David, US, Little Rock

"Karam, Sage", US, Nazareth

As you can see, this may cause a problem when importing the file into your spreadsheet application as the 4th row has 4 commas, and the others only have 3.

This is easy to fix using Awk. Simply run this one-liner command, specifying your source file, and then a new file to output it to:

awk -F'"' -v OFS='' '{ for (i=2; i<=NF; i+=2) gsub(",", "", $i) } 1' source_file.csv >processed_file.csv

Windows - How to Measure Time or Length of Command or Executable

There are serveral reasons you would want to see how long it takes to execute a command, or run a program. Perhaps you are benchmarking a command line application you made, or want to see how long it takes to run the same command on different computers. Whatever your reason, here are 3 ways to measure the time it takes to execute a command or application on Windows. In my example, I'm seeing how long it takes to perform a DNS query (you can replace the underlined portion with the command you want to time):

1. In PowerShell, run the following command:

Measure-Command {nslookup}


2. Here is a one-liner you can run from the command prompt:

cmd /v:on /c "echo !time! & nslookup & echo !time!"


3. Save this at a batch file, and then run it:

echo %time%


echo %time%


Here is a screenshot of each method:

Windows - How to Measure Time or Length of Command or Executable

Subscribe to One-Liner