Computing.Net > Forums > Unix > Append if it's wednesday

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Append if it's wednesday

Reply to Message Icon

Name: nmf
Date: August 5, 2006 at 11:10:10 Pacific
OS: osx
CPU/Ram: 256
Product: emac
Comment:

I'd like to overwrite a file if its tuesday, but any other day
of the week I'd like to append the file?



Sponsored Link
Ads by Google

Response Number 1
Name: nmf
Date: August 5, 2006 at 11:59:44 Pacific
Reply:

I figured it out

day=`date +%a`
newday="Tue"
if [ $day == $newday ];
then
cat PA.1 > PA.2
else
cat PA.1 >> PA.2
fi

I'm learning!


0

Response Number 2
Name: David Perry
Date: August 7, 2006 at 20:01:50 Pacific
Reply:


if [ `date +%w` -eq 2 ] ; then
cat PA.1 > PA.2
else
cat PA.1 >> PA.2
fi



0

Response Number 3
Name: lchi2000g
Date: August 8, 2006 at 05:24:05 Pacific
Reply:

resuable variable:

case `date +%a` in
Tue) GOTO=">" ;;
*) GOTO=">>" ;;
esac

eval cat PA.1 $GOTO PA.2

Luke Chi


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Append if it's wednesday

Unixware 2º disk it's bad! www.computing.net/answers/unix/unixware-2-disk-its-bad/1217.html

Compare 2 files if it's same r not www.computing.net/answers/unix/compare-2-files-if-its-same-r-not/8196.html

how to determine if device is busy www.computing.net/answers/unix/how-to-determine-if-device-is-busy/5376.html