Quote:
Originally Posted by neo009
Hi I got this working just i want to append date format while this will create new file in %Y%M%D format.
#!/bin/bash
echo "Enter the file to be used: \c"
read flname
if [ ! -f $flname ];
then
echo "File $flname does not exists! Please provide the exact path"
exit
else
echo "File exist using input from $flname"
fi
if [ -e $flname ];
then
read -p "Enter first line number to start input data: " n
read -p "Enter last line number to input data: " m
else
"Provide exact number of lines"
fi
num=1
while [ -e test$num ]; do
num=`expr $num + 1`
echo test_${num:1}
done
cut -c $n-$m $flname > test$num
if [ -e test$num ]; then
echo "File $test exist creating new test$num"
else
echo "File does not exists"
fi
just please guide me for appending date format...i dont want to use mv or paste..if file exist with date format then it should create new with %y%m%d-1 or %y%m%d-2 ....-3, -4 so on.
|
Hey I got it too..here is my script for appending date there..
#!/bin/bash
echo "Enter the file to be used: \c"
read flname
if [ ! -f $flname ];
then
echo "File $flname does not exists! Please provide the exact path"
exit
else
echo "File exist using input from $flname"
fi
if [ -e $flname ];
then
read -p "Enter first line number to start input data: " n
read -p "Enter last line number to input data: " m
else
"Provide exact number of lines"
fi
num=100
d=`date +%y-%m-%d`
while [ -e logfile.log-$d-$num ]; do
num=`expr $num + 1`
echo logfile.log-$d-${num:1}
done
cut -c $n-$m $flname > logfile.log-$d-$num
if [ -e logfile.log-$d-$num ]; then
echo "file exist created new"
else
echo "File does not exists"
fi
Thank you so much to both of you for helping me...