On 2019 Jun 26 23:09:20, you wrote to All:
========Script: mvbad2tic==========
#!/bin/sh
list="`ls -1 *.bad`"
for file in $list
do
f=`basename $file .bad`.tic
mv $file $f
done
===================================
that's pretty neat! another way it could be done is this oneliner...
ls -1 *.bad | \
tr '\n' '\0' | \
xargs -0 -n 1 -i basename "{}" .bad | \
tr '\n' '\0' | \
xargs -0 -n 1 -i echo mv "{}".bad "{}".tic
it seems convoluted but actually makes sense once you figure it out... plus it handles files with spaces in their names...
1. list the *.bad files one per line
2. replace newlines with nuls
3. use xargs to feed each line to basename to strip leading path and trailing .bad
4. replace newlines with nuls
5. use xargs to feed each line to mv (remove echo when you see it print the commands as you expect)
we've been using this following one with various changes depending on the extensions needed... it uses sed recipe for the change of extension and handles
files with spaces, too... you just have install rename...
rename 's/\.bad$/.pkt/' *.bad
it was very handy when first setting up the new system and traffic was already flowing while we were still configuring the tosser which was renaming a lot of pkts to bad because we were still looking up and configuring the packet passwords :lol:
)\/(ark
Always Mount a Scratch Monkey
Do you manage your own servers? If you are not running an IDS/IPS yer doin' it wrong...
... "Who stole my thermal underwear?" the hunter asked coldly.
---
* Origin: (1:3634/12.73)