Advertisement
metalx1000

BASH Paste 2 files together

Nov 15th, 2022
1,341
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2022  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation, either version 3 of the License, or
  9. #(at your option) any later version.
  10.  
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #GNU General Public License for more details.
  15.  
  16. #You should have received a copy of the GNU General Public License
  17. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18. ######################################################################
  19.  
  20.  
  21. cal > "/tmp/mycal"
  22. echo "Take out Trash
  23. Clean Bathroom
  24. Go for jog
  25. Pick up supplies" > "/tmp/mytodo.lst"
  26.  
  27. paste "/tmp/mycal" "/tmp/mytodo.lst"
  28.  
Advertisement
Comments
  • SergeySamoylov
    2 years
    # Bash 1.40 KB | 0 0
    1. #!/bin/bash
    2.  
    3. # Hi, Kris! Thank you for your help. The whole script looks like this.
    4.  
    5. set -e
    6.  
    7. readonly TODO_DIRECTORY="${TODO_DIRECTORY:-"${HOME}/Documents/todo"}"
    8. readonly TODO_EDITOR="${EDITOR}"
    9.  
    10. readonly TODO_FILE="$(date +%Y-%m-%d).md"
    11. readonly TODO_PATH="${TODO_DIRECTORY}/${TODO_FILE}"
    12.  
    13.  
    14. if [ ! -d "${TODO_DIRECTORY}" ]; then
    15.    while true; do
    16.        printf "%s does not exist, do you want to create it? (y/n) " "${TODO_DIRECTORY}"
    17.        read -r yn
    18.  
    19.        case "${yn}" in
    20.            [Yy]* ) mkdir -p "${TODO_DIRECTORY}"; break;;
    21.            [Nn]* ) exit;;
    22.            * ) printf "Please answer y or n\n\n";;
    23.        esac
    24.    done
    25. fi
    26.  
    27. if [ ${#} -eq 0 ]; then
    28.    if [ -p "/dev/stdin" ]; then
    29.        (cat; printf "\n") >> "${TODO_PATH}"
    30.    else
    31.        cal -m > "/tmp/mycal"
    32.        LC_ALL=ru_RU.utf8 date +"ToDo: %d %B, %Y" > "/tmp/mytodo.lst"
    33.        echo "====================="  >> "/tmp/mytodo.lst"
    34.        cat "${TODO_DIRECTORY}/${TODO_FILE}"  >> "/tmp/mytodo.lst"
    35.        paste "/tmp/mycal" "/tmp/mytodo.lst"
    36.        # eval "${TODO_EDITOR}" "${TODO_PATH}"
    37.    fi
    38. else
    39.    printf "%s\n" "${*}" >> "${TODO_PATH}"
    40.    cal -m > "/tmp/mycal"
    41.    LC_ALL=ru_RU.utf8 date +"ToDo: %d %B, %Y" > "/tmp/mytodo.lst"
    42.    echo "=====================" >> "/tmp/mytodo.lst"
    43.    cat "${TODO_DIRECTORY}/${TODO_FILE}"   >> "/tmp/mytodo.lst"
    44.    paste "/tmp/mycal" "/tmp/mytodo.lst"
    45. fi
    46.  
Add Comment
Please, Sign In to add comment
Advertisement