Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-22-2008, 10:00 AM   #1
LQ Newbie
Registered: Jan 2008
Posts: 6

Rep: Reputation: 0
sed or awk

Hello All, I am trying to program a script to change the ip.

I would like that the user enters
and since we use /24 masks I can just "calculate" from sed or awk

the gateway the network and the broadcast

Any help would be appreciated.
Old 08-22-2008, 10:38 AM   #2
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
You can do this quite easily with a shell script and internal string manipulation - no need to invoke other processes:

read -p "enter the IP> " ip

printf "%-20s = %s\n" "ip" "$ip"
printf "%-20s = %s\n" "gateway" "$gateway"
printf "%-20s = %s\n" "network" "$network"
printf "%-20s = %s\n" "broadcast" "$broadcast"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SED/AWK help bioinformatics_guy Linux - Newbie 1 08-12-2008 05:07 AM
awk or sed help cmontr Programming 16 05-14-2008 10:59 AM
awk and/or sed linux2man Linux - General 7 01-22-2007 10:02 AM
Sed and Awk Gins Programming 7 04-19-2006 10:32 AM
awk/sed help pantera Programming 1 05-13-2004 11:59 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:00 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration