NAWK question

Hello everybody !!

I just started messing around with NAWK/AWK and I find it very interesting. I was trying to have script that prints only the the different lines (lines that are identical and adjacent, some that are identical and not adjacent, and some that are just different)

I tried direclty using the command line (awk '$1 != previous { print; previous = $1 }' file)

I am trying to do it in a script.

Your help will be appreciated :slight_smile:

I think I figured it out !!

Thanks anwyays.

I have another question :slight_smile:

I'm trying to do a fold script similar to the one built in the system. For ex, let say I wanna fold lines at 80 columns ( given input with lines that are 120 columns long, it prints the first 80 characters of each line, a new line, and then the remaining 40 characters )

Thanks in advance

awk '{s1=substr($0,1,80);s2=substr($0,81);print s1;print s2}' file

Thanks,

How can I do that in a script

Im just tryin to learn how to do things in script form, not in command line.

Thanks shamrock

I did figure out.

Is there a way where I can input the columns number at the command line ? or not

I figured it out :slight_smile: