Forums Register Login

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

+Pie Number of slices to send: Send
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..!!
1
+Pie Number of slices to send: Send
Doing a or should help.

Try

hope this helps,
- Anand
1
+Pie Number of slices to send: Send


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.
no wonder he is so sad, he hasn't seen this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1885 times.
Similar Threads
Search on a string
I want my ant script Implement a function
mysql database restore
Need help for Shell Script to reduce a file
Array Index out of range issue
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:10:49.