Running multiple commands in one line in shell

You are using | (pipe) to direct the output of a command into another command. What you are looking for is && operator to execute the next command only if the previous one succeeded: cp /templates/apple /templates/used && cp /templates/apple /templates/inuse && rm /templates/apple Or cp /templates/apple /templates/used && mv /templates/apple /templates/inuse To summarize (non-exhaustively) … Read more

How to increment a date in a Bash script

Use the date command’s ability to add days to existing dates. The following: DATE=2013-05-25 for i in {0..8} do NEXT_DATE=$(date +%m-%d-%Y -d “$DATE + $i day”) echo “$NEXT_DATE” done produces: 05-25-2013 05-26-2013 05-27-2013 05-28-2013 05-29-2013 05-30-2013 05-31-2013 06-01-2013 06-02-2013 Note, this works well in your case but other date formats such as yyyymmdd may need … Read more