Pipe output missing date?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pipe output missing date?
# 1  
Old 02-26-2013
Pipe output missing date?

I'd like to have the output from this script piped to a text file that has the date at the beginning of it. For example, my ideal would be something like this

$./run_script.sh
$ls *.out
2013-Feb-26-output_filename.out

Here's the code I'm using.
Code:
#! /bin/ksh

DAT=`date '+%Y-%b-%d'`

for d in /dir1 /dir2 /dir3

do
   df -h $d|tail -1

done|>> $DAT_disk_usage.out

Instead of the output I'm expecting I get nothing... what am I missing?
# 2  
Old 02-26-2013
Code:
for d in /dir1 /dir2 /dir3
        df -h "$d" | tail -1
done >> "${DAT}_disk_usage.out"

This User Gave Thanks to Yoda For This Post:
# 3  
Old 02-26-2013
That worked like a champ. Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Print Date when Broken Pipe happens

Hi all, as i have multiple broken pipes on ssh sessions, i need to find out after how much time it happens, ssh root@testServer root@testServer's password: ssh:notty Last login: Thu Apr 6 06:41:16 2017 from 10.10.10.2 # but when broke pipe happen i don't have any idea after how much... (3 Replies)
Discussion started by: charli1
3 Replies

2. Shell Programming and Scripting

How to pipe a filename that includes a date?

How do I pipe the output of something to a filename that includes the date, in a specific date format? Here's the goal. Output a script to a file periodically during the day: ./script.sh >>logname_yyyy-mm-dd.logAnd when the next day comes, it starts logging to a new filename because the date... (2 Replies)
Discussion started by: nbsparks
2 Replies

3. Shell Programming and Scripting

Coulering pipe output

I'm trying to get an output to echo on the next line in a given color and outputted next to a label. Sorry if that's a bit vague, see below. #!/bin/bash YELLOW=$(tput setaf 3 && tput bold) echo -n 'plaintext' | openssl md2 || read hash echo "$YELLOW Hash:$hash" But I can't seem to get the... (2 Replies)
Discussion started by: 3therk1ll
2 Replies

4. Shell Programming and Scripting

How to get the missing date and day in a table?

Hi Am using unix Aix Ksh Have Created table called vv and i have inserted two date Select * from vv; Output :- New_date 21/02/2013 24/02/2013 I have tried Using One query but Unsuccessful so far.. SELECT l.new_date + '1 day' as miss from vv as l (7 Replies)
Discussion started by: Venkatesh1
7 Replies

5. Shell Programming and Scripting

How to find the Missing date inside the FILE?

Hi am using Unix AIX Ksh have a FILE CAT FILE 08/02/2013 16/02/2013 18/02/2013 I need the Outputs as Missing date are 09/02/2013 to 15/02/2013,17/02/2013 can anyone help me !!! (1 Reply)
Discussion started by: Venkatesh1
1 Replies

6. Shell Programming and Scripting

[Solved] missing date in unix

i have a file with below contents Mg_Message_count,1-Aug-12,46 Mg_Message_count,2-Aug-12,48 Mg_Message_count,3-Aug-12,48 Mg_Message_count,4-Aug-12,48 Mg_Message_count,5-Aug-12,48 Mg_Message_count,6-Aug-12,48 Mg_Message_count,7-Aug-12,42 Mg_Message_count,20-Aug-12,24... (10 Replies)
Discussion started by: rabindratech
10 Replies

7. Shell Programming and Scripting

Missing date

hi team, i have a file contains data as follows F1 file --------------------------- date system name 1-jan-2012 x 1-jan-2012 y 1-jan-2012 x 5-jan-2012 y 3-jan-2012 z 3-jan-2012 z 4-jan-2012 x 4-jan-2012 x ... (13 Replies)
Discussion started by: rabindratech
13 Replies

8. UNIX for Dummies Questions & Answers

Using multiple pipe output

I have a script that finds all sffs and extracts them into .fastq file types. What I need to do is change the .fastq to .fasta using the below script. How can I change the input.fastq and output.fasta to mirror the file's name? Would I use an array and use the default iterator? #!/bin/bash ... (3 Replies)
Discussion started by: jrymer
3 Replies

9. UNIX for Dummies Questions & Answers

pipe > output

I can use pipe output to a file. For example ./somescript.sh > output.txt But for example if the output from ./somescript.sh is slow. like if it prints one line every minute then output.txt is not updated every minute. Lines are written to output.txt in one go, hence have to wait for the whole... (2 Replies)
Discussion started by: kevincobain2000
2 Replies

10. Shell Programming and Scripting

pipe to file named with date

I would like to pipe (redirect ? - what is the right term?) the output of my script to a file named with the current date. If I run this at a command prompt: date +'%Y%m%d" ...it returns "20110429" OK, that's good... so I try: ./script.sh > "'date +%Y%m%d'.csv" I get a file... (1 Reply)
Discussion started by: landog
1 Replies
Login or Register to Ask a Question