Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read last line from multiple files and redirect it into a single file using Linus script.

 
Ashwin Kumar Balasubramanian
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I got a folder named Server_logs. Inside that there are 20 files named in following way.

data_log_192.168.27.1.log
data_log_192.168.27.2.log........ so on till
.
.
.
data_log_192.168.27.19.log

These files differ only from their IP address. I want to open up each file and read only the last line from these files. the last line has the following information " 129G 39G 84G 32% /data ". and redirect these data's from other files into a single file.
Can anyone write a script and give me please. Am totally new to Linux and am not getting the proper code to write.
Please Help..!!
 
Anand Hariharan
Rancher
Posts: 272
C++ Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doing a or should help.

Try

hope this helps,
- Anand
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18162
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Note that the "ls" command is quoted using back-tick characters, not normal (apostrophe) single-quite characters. The difference is critical.

An alternative notation might be "$(( ls Server_logs/*.log ))", but without actually trying it I'm not sure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic