• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 14:47
CET 20:47
KST 04:47
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Rongyi Cup S3 - Preview & Info3herO wins SC2 All-Star Invitational14SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0
Community News
Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win3Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)38
StarCraft 2
General
StarCraft 2 not at the Esports World Cup 2026 Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win Oliveira Would Have Returned If EWC Continued herO wins SC2 All-Star Invitational PhD study /w SC2 - help with a survey!
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open! SC2 All-Star Invitational: Jan 17-18 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 510 Safety Violation Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained
Brood War
General
Potential ASL qualifier breakthroughs? BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ Bleak Future After Failed ProGaming Career [ASL21] Potential Map Candidates
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 Azhi's Colosseum - Season 2 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Simple Questions, Simple Answers Zealot bombing is no longer popular? Current Meta Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Battle Aces/David Kim RTS Megathread Path of Exile Nintendo Switch Thread Mobile Legends: Bang Bang Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread YouTube Thread Canadian Politics Mega-thread European Politico-economics QA Mega-thread
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
How Esports Advertising Shap…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1800 users

Shell Scripting Newb

Blogs > TheAmazombie
Post a Reply
TheAmazombie
Profile Blog Joined September 2010
United States3714 Posts
Last Edited: 2012-11-16 23:03:39
November 16 2012 21:55 GMT
#1
Well, so maybe not a total newb, but I haven't done it in a while. I used to do bash and zsh scripting a lot back when I had a use for it, but I have not even opened vi or emacs or whatever in at least 2 years. Mind you, I was never a pro at it, but I could get around well enough to write little automation scripts to make my job easier.

So today I started writing a new little script to automate one of my normal everyday functions, but I am having issues with how to construct it here. I was able to pull some info from google and my old scripts, but after much digging it appears that only a few of my old ones still exist. Most seem to have been lost. Google, when it comes to code, it not always the best though because it will sometimes give you similar examples, but most of the time nothing exactly like what you need or you get a ton of random things, some might work, others not.

I am using an nmap -sP sweep ping to sort through IPs on certain subnets. That is the easy part. I also have a nice, clean menu system in place (via and until, do, and case function), but really where I am getting lost again is in parsing and formatting.

I am going to give an example of what I am getting. Mind you, IPs and Hostnames are different as to not give out some of that personal info. Anyway, here is my example command:

nmap -sP 10.10.16.0/22 | grep fun


...then my results return:

Host fun-test1.practice.com (10.10.16.148) appears to be up.
Host fun-test2.practice.com (10.10.16.150) appears to be up.
Host fun-test3.practice.com (10.10.16.158) appears to be up.
Host fun-test4.practice.com (10.10.16.159) appears to be up.
Host fun-test5.practice.com (10.10.16.162) appears to be up.
Host fun-test6.practice.com (10.10.16.165) appears to be up.
Host fun-test7.practice.com (10.10.16.166) appears to be up.
Host fun-test8.practice.com (10.10.16.167) appears to be up.
Host fun-test9.practice.com (10.10.16.169) appears to be up.


Of course I get all host info from my sweep ping on the .16.0 network segment which begin with the word "fun." This is what I want. Now, here is where I can't seem remember how to go about doing and I am hoping that TL scripters can give me a nudge in the right direction...

What I want is to compare this info to a pre-set list of hostnames and IPs, use that info to compile a new list of all hosts that are NOT up, then return that info in something similar to:

Host fun-test10.practice.com (10.10.16.14) appears to be available.
Host fun-test20.practice.com (10.10.16.50) appears to be available.
Host fun-test30.practice.com (10.10.16.58) appears to be available.
Host fun-test40.practice.com (10.10.16.59) appears to be available.
Host fun-test50.practice.com (10.10.16.62) appears to be available.
Host fun-test60.practice.com (10.10.16.15) appears to be available.
Host fun-test70.practice.com (10.10.16.16) appears to be available.
Host fun-test80.practice.com (10.10.16.17) appears to be available.
Host fun-test90.practice.com (10.10.16.19) appears to be availabe.


Now, it dawns on me that I don't have the slightest recollection on how to do that...if I could just get a tiny push in the right direction, it might be helpful. Or hell, just tell me this is a stupid idea for a script and to just give up...that might help. Haha.
I know that I used to do thins kind of thing with a "for each do" type of statement, but those were always inclusive, not exclusive...so now I am lost.


Damn you linux! Why do I torture myself, slaving away at you, all day long!

*****
We think too much and feel too little. More than machinery, we need humanity. More than cleverness, we need kindness and gentleness. Without these qualities, life will be violent and all will be lost. -Charlie Chaplin
TheAmazombie
Profile Blog Joined September 2010
United States3714 Posts
November 16 2012 23:01 GMT
#2
LoL. Well, I got my cuts to work in formatting finally. I have always had issues with the cut output modifiers and arguments. I needed some help from one of my buddies how got me this:

nmap -sP 10.10.16.0/22 | grep fun | cut -d" " -f2,3 | tr -d "()"


That at least gives me the raw data that I need to work with, outputting this:

fun-test1.practice.com 10.10.16.148
fun-test2.practice.com 10.10.16.150
fun-test3.practice.com 10.10.16.158
fun-test4.practice.com 10.10.16.159
fun-test5.practice.com 10.10.16.162
fun-test6.practice.com 10.10.16.165
fun-test7.practice.com 10.10.16.166


Now I just need to do the comparison...
We think too much and feel too little. More than machinery, we need humanity. More than cleverness, we need kindness and gentleness. Without these qualities, life will be violent and all will be lost. -Charlie Chaplin
Please log in or register to reply.
Live Events Refresh
Next event in 16h 14m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
JuggernautJason228
ProTech143
BRAT_OK 104
Livibee 27
StarCraft: Brood War
Rain 5393
Larva 1045
BeSt 180
Dewaltoss 161
Shuttle 124
League of Legends
C9.Mang081
Counter-Strike
fl0m4171
pashabiceps1431
kRYSTAL_20
Heroes of the Storm
Liquid`Hasu415
Other Games
gofns14912
Grubby3842
FrodaN1730
ToD211
QueenE154
ArmadaUGS144
mouzStarbuck96
Mew2King89
KnowMe33
fpsfer 1
Organizations
StarCraft 2
angryscii 44
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 20 non-featured ]
StarCraft 2
• StrangeGG 59
• Adnapsc2 14
• intothetv
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• 80smullet 29
• blackmanpl 28
• FirePhoenix2
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV652
League of Legends
• Nemesis5338
• imaqtpie1807
• TFBlade1526
• Shiphtur314
Upcoming Events
HomeStory Cup
16h 14m
Korean StarCraft League
1d 7h
HomeStory Cup
1d 16h
Replay Cast
2 days
HomeStory Cup
2 days
Replay Cast
3 days
Replay Cast
4 days
Wardi Open
4 days
WardiTV Invitational
5 days
The PondCast
6 days
[ Show More ]
WardiTV Invitational
6 days
Liquipedia Results

Completed

Proleague 2026-01-28
OSC Championship Season 13
Underdog Cup #3

Ongoing

CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Acropolis #4 - TS4
Rongyi Cup S3
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025

Upcoming

Escore Tournament S1: W6
Escore Tournament S1: W7
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
LiuLi Cup: 2025 Grand Finals
HSC XXVIII
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.