Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was reading this awk script

awk -F"=" '{OFS="=";gsub(",",";",$2)}1'

I want to know what is the function of 1 at the end of it

share|improve this question
up vote 13 down vote accepted

An awk program is a series of condition-action pairs, conditions being outside of curly braces and actions being enclosed in them. A condition is considered false if it evaluates to zero or the empty string, anything else is true (uninitialized variables are zero or empty string, depending on context, so they are false). Either a condition or an action can be implied; braces without a condition (as yours begins) are considered to have a true condition and are always executed if they are hit, and any condition without an action will print the line if and only if the condition is met.

The 1 at the end of your script is a condition (always true) with no action, so it executes the default action for every line, printing the line (which may have been modified by the previous action in braces).

share|improve this answer

1 means to print every line.

The awk statement is same as writing:

awk -F"=" '{OFS="=";gsub(",",";",$2);print $0;}'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.