Computing.Net > Forums > Unix > Increment a number using awk or sed

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Increment a number using awk or sed

Reply to Message Icon

Name: salman4983
Date: April 5, 2005 at 12:11:34 Pacific
OS: Windows XP
CPU/Ram: 2.8 GHz/512 MB
Comment:

Need help with awk or sed script. I have multiple files with the following in first line
NUMBER_COLUMNS=15

I want to increase the number by 1 so it should say
NUMBER_COLUMNS=16

Thanks .....


salman



Sponsored Link
Ads by Google

Response Number 1
Name: Jim Boothe
Date: April 6, 2005 at 10:29:29 Pacific
Reply:

awk -F= '\
{if (NR==1 && $1=="NUMBER_COLUMNS")
    print "NUMBER_COLUMNS=" $2+1
 else
    print}'


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Increment a number using awk or sed

Editing a file without awk or sed www.computing.net/answers/unix/editing-a-file-without-awk-or-sed/5437.html

Sed or Awk help www.computing.net/answers/unix/sed-or-awk-help/6447.html

Compare two files using awk or sed, add value www.computing.net/answers/unix/compare-two-files-using-awk-or-sed-add-value/8499.html