• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..!!
 
Rancher
Posts: 280
VI Editor C++ Debian
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doing a or should help.

Try

hope this helps,
- Anand
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic