Code:
date >> date.txt && echo "something start" >> date.txt
That gives me
Code:
Sun May 17 01:08:28 BRT 2015 something start
How to get both at the same line? Like this
Code:
Sun May 17 01:08:28 BRT 2015 something start
date >> date.txt && echo "something start" >> date.txt
Sun May 17 01:08:28 BRT 2015 something start
Sun May 17 01:08:28 BRT 2015 something start
read dateStrNew dateStrOld < <(curl -k -q "$curl_call" | html2text | gawk '/Newest Sequence/ { new=$3" "$4 }/Oldest Sequence/ \ {old=$3" "$4}END {OFS=","; print new,old }') //new = date, old = date
export HISTTIMEFORMAT="%d/%m/%y %T "
host_list=("c15-0330-01.ad.mtu.edu" "c15-0330-02.ad.mtu.edu" "c15-0330-03.ad.mtu.edu" "c15-0330-04.ad.mtu.edu") program=("L_1" "L_4" "L_3" "L_4") subject="The job is finished" START=$(date +"r") address="/home/campus27/zwang10/Desktop/AWRR/program/power/vmodel_1/nprot/K_10" ssh -f "${host_list[0]}" "cd '$address' && nohup Rscript '${program[0]}.R' > '${program[0]}_sh.txt';echo 'The job\n $address\n${program[0]} is finished\nSTART TIME = $START\n' END TIME =`date +"%r"` | mutt zwang10@mtu.edu -s '${host_list[0]} - Job ${program[0]}.R finished' -a '$address/${program[0]}_sh.txt';"
#!/bin/ksh filename="/apps/log/file.txt" if [ -f "${filename}" ] then createTime=`ls -lad "${filename}" | awk '{print $8}'` echo "$createTime" currentTime=`date '+%M'` echo "$currentTime" DIFF=$(( $currentTime - $createTime )) echo "$DIFF" else exit 1 fi
# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command */10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav
/usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav
PREFIX=192.168.1 OCTET=1 while [ $OCTET -lt "255" ]; do echo -en "Pinging ${PREFIX}.${OCTET}..." ping -c1 -w1 ${PREFIX}.${OCTET} > /dev/null 2>&1 if [ "$?" -eq "0" ]; then echo "OK" else echo "Failed" fi let OCTET=$OCTET+1 done
let $OCTET=$OCTET+1
Sun Dec 21 03:53:42 SGT 2014 > cat test5.sh #!/bin/bash echo "Please enter value for name :" read name echo "Your name is $name." echo "Next echo will be a syntax error" ehco
Sun Dec 21 03:53:46 SGT 2014 > test5.sh 1> output.txt 2> error.txt Noob Sun Dec 21 03:54:56 SGT 2014 > cat output.txt Please enter value for name : Your name is Noob. Next echo will be a syntax error Sun Dec 21 03:55:23 SGT 2014 > cat error.txt /home/alan/scripts/test5.sh: line 8: ehco: command not found Sun Dec 21 03:55:26 SGT 2014 >
Sun Dec 21 03:59:14 SGT 2014 > test5.sh > output.txt 2>&1
test5.sh 2>&1 1>output.txt or test5.sh 2>&1>output.txt ?