Scripts for Linux
Last Updated 2020-10-29 by Adam Lu
Scripts only in this directory
Note: Regardless of location, these scripts could be run with the command:
bash ~/Settings_Linux/scripts/<scriptname>.sh
- backup_scripts: Older versions of many scripts
- backup_settings.sh: Backs up
/etc
,/proc
files and cron jobs to thebackup_settings
folder- Note: To add directories or files to back up, edit the dirsToBackup or filesToBackup array
- setup_binfiles.sh: Copies shell scripts from the current directory to
/usr/local/bin/
- Note: To add files, edit the filesToStore array and update it in store_binfiles.sh as well
- store_binfiles.sh: Copies shell scripts from
/usr/local/bin/
to the current directory- Note: To add files, edit the filesToStore array and update it in setup_binfiles.sh as well
- store_dotfiles.sh: Copies configuration files from the home directory to the current directory and append user name
- Note: To add files, edit the filesToStore array and update it in setup_dotfiles.sh as well
Scripts copied to /usr/local/bin
Note: Regardless of location, these scripts could be run with the command:
bash <scriptname>.sh
Note: You can edit these scripts here, then update them in /usr/local/bin
with the commands:
cd ~/Settings_Linux
git_update
bash setup_binfiles.sh
-
create_new_script.sh: Creates a new shell script with a given name starting from template.sh (see vi_new_script.sh, nano_new_script.sh)
-
vi_new_script.sh: Creates a new shell script with a given name starting from template.sh and opens it with the vim editor
-
nano_new_script.sh: Creates a new shell script with a given name starting from template.sh and opens it with the nano editor
-
git_update.sh: Syncs .git local repository with remote repository, commits new changes then syncs with remote repository again
-
git_all_update.sh: Runs git_update.sh on all blabuva repositories
-
filetypes.sh: Returns file types for all files in a given directory
-
ls_numfiles.sh: Lists the number of files in each subdirectory of a given directory
-
modlunit_all.sh: Runs modlunit (a NEURON program for checking code and units) for all .mod files in a given directory
-
cleanup_cache.sh: Cleans up cached folders that are no longer needed
-
cleanup_swap.sh: Cleans up swap partition and cached memory
-
swap2ram.sh: Moves swap to RAM if possible (see cleanup_swap.sh)
-
setup_all_homedirs.sh: Sets up all home directories
-
setup_homedir.sh: Sets up .desktop files, configuration files and links and removes unnecessary files in a user’s home directory
-
setup_links.sh: Sets up links for a user’s home directory
- Note: To add directories to link, edit the dirsToLink array
-
setup_desktopfiles.sh: Copies useful
.desktop
files to a user’s Desktop directory- Note: To add
.desktop
files, edit the usrSharePrograms array
- Note: To add
-
setup_dotfiles.sh: Copies configuration files from the current directory to a user’s home directory
- Note: To add files, edit the filesToStore array and update it in store_dotfiles.sh as well
-
backup_to_chalkboard.sh: Backs up data from other computers to chalkboard
- Note: To add directories, edit the sourceDirs and destDirs array simultaneously
-
backup_to_fishfish.sh: Backs up data from other computers to fishfish
- Note: To add directories, edit the sourceDirs and destDirs array simultaneously
-
notice_blanimal.sh: Generates blanimal Notice and sends it to everyone in an email list based on a Google spreadsheet
-
notice_blanimal_for_testing.sh: Generates an email (blanimal Notice) and send to Adam or Brian
-
notice_census_today.sh: Generates today’s primary and backup census takers
-
notice_census_future.sh: Generates primary and backup census takers for the following week
-
notice_colony_today.sh: Generates primary and backup colony checkers for today
-
notice_colony_future.sh: Generates primary and backup colony checkers for the following week
-
notice_wean.sh: Generates wean information for today
-
notice_genotype.sh: Generates genotype information for today
-
combine_all_current_notebooks.sh: Calls combine_current_notebooks.sh for many users
- Note: To add the name of a student, edit the gradNames or undergradNames array
-
combine_current_notebooks.sh: Concatenates all pdf files under
/media/shareX/type_books/name
into a single pdf file calledname_notebook.pdf
, then upload the file to the AWS S3 bucket. This file is placed under/home/grads
if type == “grad” and under/home/undergrads
if type == “undergrad”. The concatenation is defined in combine_notebooks.sh) -
combine_notebooks.sh: Concatenates all pdf files under inputDir into a single pdf file. The concatenation goes in reverse order according to YYYYMMDD, assuming that the original files are named as MMDDYYYY.pdf
-
notice_happy.sh: Sends emails for happy hour for every nDaysBefore based on Google spreadsheets
- Note: To change the frequency of emails, edit the nDaysBeforeAll array
-
happy_message_maker.sh: Makes a message for happy hour and places it into messagePath
-
notice_blunch.sh: Sends emails for blunch for every nDaysBefore based on Google spreadsheets
- Note: To change the frequency of emails, edit the nDaysBeforeAll array
- Note: To add people to the email list, edit the names and emails array
-
blunch_message_maker.sh: Makes a message for blunch and places into messagePath
-
aws_post_files.sh: Posts files to the webfiles directory on AWS
- Note: To add files to post, edit the filesToPost array
-
aws_update_dirs.sh: Updates directories to AWS
- Note: Needs to be cleaned
-
aws_papers_updater.sh: Uploads PDF files to AWS and creates HTML chunk code
-
wp_papers_html_email.sh: Sends emails for updated WordPress HTML code
-
wp_papers_html_writer.sh: From a given inFolder, uploads new PDF files and generate WP HTML code
-
create_readme_from_links.sh: Creates a README.md from a directory of .url links
-
create_readme_from_images.sh: Creates a README.md for a directory of images
-
create_readme_from_mscripts.sh: Creates a README.md from a directory of .m scripts
-
create_readme_from_files.sh: Creates a README.md for a directory based on the contents
-
create_readme_from_weblinks.sh: Creates a README.md for a directory of .url weblinks
-
watch_all_readmes.sh: Start automatic updates for README.md files in designated directories
-
watch_readme.sh: Watches the README.md from a directory
-
mount_all_disks.sh: Mounts all detected disks according to their label
- adams_commands.sh: Custom commands available in the command line by Adam Lu
Note: Please check out the documentation before each function name for more detailed usage
- plier: Multiplies together a sequence of numbers
- iseven: Returns 0 if an integer is even or 1 if an integer is not even
- nevens: Prints the number of even integers within a sequence of integers
- howodd: Prints the percentage of odd integers in a sequence of integers
- fib: Prints the number of Fibonacci numbers specified
- range: Takes an integer as an argument and prints all of the integers
- extremes: Prints the maximum and minimum values of a sequence of numbers
- rand_word: Prints a random word from the built-in dictionary
- tagged_copy: Creates a tagged copy of file(s)
- dated_copy: Creates a dated copy of file(s)
- timed_copy: Creates a time-stamped copy of file(s)
- timed_log: Creates a time-stamped .log file from standard input
- ismember: Returns whether a string is contained in an array
- idxmember: Returns the index of a string in an array
- str_prepend: Prepends a string to each string in an array
- str_append: Appends a string to each string in an array
- fileext: Returns the file extension of a file
- filetype: Returns a message about the file type
- standardize_path: Returns a full path with no terminal /
- url: Retrieves the URL from a .url file
- add_IP: Adds an IP address to the firewall for ports
- checkcp: Copies a file only if two files are different
- checkrm: Checks if a file exists before removing
- archive: Backs up files or directories with rsync or pseudofiles with checkcp
- create_backup_path: Creates a backup dir or file name based on original path
- create_sample_path: Creates a sample file name based on original path
- get_user_ID: Retrieves the user ID of a user
- get_group_ID: Retrieves the group ID of a user
- get_full_name: Retrieves the full name of a user
- chowner: Changes owner and group of a file based on username
- chmodifowner: Changes permissions of a file if the current user is the owner
- checkdir: Checks if a directory exists and creates it if not
- spaces2dashes: Converts spaces to dashes
- all_image_files: Returns a list of image files in a directory
- is_image: Checks if a file is an image
- is_weblink: Checks if a file is an weblink
- is_mscript: Checks if a file is a MATLAB script
- is_shscript: Checks if a file is an shell script
- is_textfile: Checks if a file is a text file or a log file
- is_csvfile: Checks if a file is a csv file
- is_markdown: Checks if a file is a markdown file
- is_folder: Checks if a file is an existing directory
- is_file: Checks if a file is an existing file
- is_filetype: Checks if a file is a given filetype
- topcommand: Calls top for a particular command
- htopcommand: Calls htop for a particular command
- killcommand: Kills all processes for a particular command
- print_readme_header: Prints the header for a README.md file
- update_readme_header: Updates the header for a README.md file
- get_description_from_mscript: Get the description from a .m script
- get_description_from_shscript: Get the description from a .sh script
- get_description_from_filename: Get the description from a file name
- grep_line_numbers: Finds the line numbers that match a pattern in a file
- get_git_repository_name: Retrieves the git repository the file is contained in
- bulk_subtract: Subtract a number from a list of numbers
- bulk_add: Add a number to a list of numbers
- template_function: A template function to modify from
- TODO
- create_readme_from_images.sh: Creates a README.md for a directory of images
- get_timestamps.py
- notice_undergrad_tasks.sh: Sends emails for undergrad tasks
- sample scripts
- git_all_update.sh: Runs git_update.sh on all blabuva repositories
- git_update.sh: Syncs .git local repository with remote repository, commits new changes
- backup_to_fishfish.sh~
- copy_and_rename_recordings.sh: Copy and rename recordings (.abf files) based on markdown notes
Note: Please check out the documentation before each function name for more detailed usage
- copy_and_rename_recordings_helper: copies and rename recordings
- create_matlab_links.sh: TODO: This is a template file for a new shell script
Note: Please check out the documentation before each function name for more detailed usage
- functionName: TODO