- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: loop script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2004 07:22 AM
06-15-2004 07:22 AM
loop script help
create the output file containg the following information from all of .csv files in /admin directory. The output file convention is "transmission_YYYYMMDDHHMMSS.txt"
name of a file size of a file lines in a file
example)
$ cat /admin/transmission_20040615112003.txt
06152004191647.csv 77KB 1257
06152004102629.csv 171KB 2800
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2004 07:38 AM
06-15-2004 07:38 AM
Re: loop script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2004 07:45 AM
06-15-2004 07:45 AM
Re: loop script help
OTPF=transmission_$(date +%Y%m%H%M%S).txt
cd /admin
/bin/ls -1 *cvs|while read CVS;do
SIZE=$(/bin/ls -ls $CVS|awk '{printf("%d KB",$6/1024)}'
STR=$(cat $CVS |wc -l)
echo $CVS $SIZE $STR
done > $OTPF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2004 10:18 AM
06-15-2004 10:18 AM
Re: loop script help
Heiner got a good solution for you as he hit size and count in one shot. Just replace "> /admin/output.txt " with
> /admin/transmission_$(date +%Y%m%d%H%M%S).txt
You will have to add 'cd /admin' before it if you are planning to run this script through cron or so.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2004 08:54 PM
06-15-2004 08:54 PM
Re: loop script help
The creation of transmission file contains the informations with seconds and minutes. The completion of .csv file search operation will take more seconds. So don't predefine the file with some variable in the shell. Use that at redirection.
#!/usr/bin/ksh
set -x
/usr/bin/ls -l *.csv | awk '{ print $9 }' | while read file; do
/usr/bin/ls -l $file | awk '{ print $9 " "$5/1024" KB "$5 ""}'
done > /admin/transmission_$(date +%Y%m%H%M%S).txt
Regards,
Muthukumar