Aug. 6th, 2007

sbc_compliant: (Default)
So, I had a list of items upon which I wanted to run a command.

The command required 2 arguments:
a) the list item and
b) the list item modified by a character substitution

I finally figured out how to mod the variable, and feed it in to my command, thusly:

for item in `cat list.txt`; do command `echo $item | sed 's/char1/char2/'` $item; done


Hooray sed!



p.s. Yes, I only needed the first instance of char1 on the line replaced. That's why I didn't use the trailing g in the sed replacement.
sbc_compliant: (Default)
So, I had a customer today that had mistakenly added a bunch of hosts en masse to a config file via a GUI tool. The tool, however, does not allow for mass removal. So, the ticket came to me.

I removed the hosts from the config file using the magic of seq!

  • for i in `seq -w 036 1 200`; do command -rm "remove per [ticket_number]" host-complex$i.system.domain.tld; done


That -w flag is really handy for keeping the padding zeros in place, especially since the customer had started at such a non-round number.

Profile

sbc_compliant: (Default)
sbc_compliant

November 2019

S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 10th, 2026 08:11 am
Powered by Dreamwidth Studios