How can I create a file in unix or linux based on variable value ?
Ex:
If I store date in a variable in linux,
YESTERDAY=`date --date='1 day ago' '+%d-%m-%Y'`
it will store value to YESTERDAY as 27-1-2010.
Here I want to create file as name of 27-1-2010,
How can I create file with variable 'YESTERDAY' ?
i want appending operation too. How can i do this ?
From serverfault
Kumar P
-
touch $YESTERDAYor
echo "something" > $YESTERDAYto append:
echo "something" >> $YESTERDAYFrom Dennis Williamson -
I don't see anything wrong with
echo "foo" >> $YESTERDAYorcat otherfile >> $YESTERDAYWhat are you trying to cat? Or alternately what are you trying to put into the file called 27-1-2010?
From jrod -
You can use the variable
$YESTERDAYin commands. Liketouch $YESTERDAY,mv original_file $YESTERDAYFrom Rory McCann -
YESTERDAY=
date --date='1 day ago' '+%d-%m-%Y'cat >> $YESTERDAY
It too working well with appending operation
From Kumar P
0 comments:
Post a Comment