a peek into my MIND

March 15, 2010

There is always something to learn in Linux ‘Bash’ shell

Filed under: General — Tags: , , , — Bharat Kondeti @ 11:08 pm

In my current project all our logs are mounted onto a Linux machine for easy access and they are numbered systematically like server 1 to 6 with side A and side B. We have a daily append-er for our application logs, so at any given time we will have file’s with same name’s on all the servers. For Ex.

/opt/logs/server1_A/log_2010-03-12.log
/opt/logs/server1_B/log_2010-03-12.log
……
……
/opt/logs/server6_A/log_2010-03-12.log
/opt/logs/server6_B/log_2010-03-12.log

Some interesting things can be done with this kind of setup. To start off, to list all the files of a particular day one can use Square Bracket Wild cards.

ls -all /opt/logs/das[1-6]_[AB]/log.2010-03-15.log

ls -all /opt/logs/das[123456]_[AB]/log.2010-03-15.log

(more…)

Create a free website or blog at WordPress.com.