I have a csv (large) file of ip addresses, and wish to covert into single line ip address in bash.
aa.bb.cc.dd,aa.bb.cc.dd,aa.bb.cc.dd,..
into
aa.bb.cc.dd
aa.bb.cc.dd
aa.bb.cc.dd
[..]
The list of ips in question,
I have a csv (large) file of ip addresses, and wish to covert into single line ip address in bash.
aa.bb.cc.dd,aa.bb.cc.dd,aa.bb.cc.dd,..
into
aa.bb.cc.dd
aa.bb.cc.dd
aa.bb.cc.dd
[..]
The list of ips in question,
cat file | tr ',' '\n' > fixed.txt
tr does simple character translation (and much more but thats what its doing here). this just translates all the commas to newlines.
Assuming that file is not on your server, this will do all the work for you in one line:
curl http://www.stopforumspam.com/downloads/bannedips.zip | gunzip -c | sed s/,/\\n/g > bannedips.txt
You can't use unzip for this, if you want it flying through the pipes.
Thanks for the suggestion Dennis!
gunzip -c instead of unzip. curl ... | gunzip -c | sed ...