kkt008
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 2022 UC Carpentries Fall Workshop (The Unix Shell) **Workshop Details** Dates: September 6th - 13th, 2022 Time: 9am - 12pm **Workshop Agenda:** https://ucsdlib.github.io/2022-09-06-carpentries-uc/ ## Day 4: The Unix Shell **Software Installation:** **Git for Windows - Windows** Windows: https://gitforwindows.org * download the Git-2.33.0.2-64-bit.exe * Git win 64 bit Direct download link https://github.com/git-for-windows/git/releases/download/v2.33.0.windows.2/Git-2.33.0.2-64-bit.exe Mac users will use the built-in Terminal application required for Unix Shell and Git lesson Recommended Text editors to use: **Nano** * Part of Git for Windows isntaller (called GitBash) * MacOS Terminal **Notepad++ (optional text editor)** * https://notepad-plus-plus.org/downloads/ * Download latest version Notepad++ **Lesson Data (download)** * https://librarycarpentry.org/lc-shell/data/shell-lesson.zip * Download shell-lesson.zip and move the file to your Desktop * Unzip/extract the file. You should end up with a new folder called shell-lesson on your Desktop. ## NOTES: **What is the shell?** Intro slides: https://docs.google.com/presentation/d/1JvAk7a-SgYUN4y8xXtQKB2Z2iwup0hEfJZmsZ-xlJ5Q/edit?usp=sharing **Navigating the filesystem** Webpage for help using the shell on windows machines: http://man.he.net/ **Working with files and directories** **Automating the tedious with loops** More about shell scripts: https://ryanstutorials.net/bash-scripting-tutorial/ **Counting and mining with the shell** Regular Expressions resources: LC regex cheatsheet: https://librarycarpentry.org/lc-data-intro/reference.html regex101:https://regex101.com/ regexper: https://regexper.com/ Regex Testing: https://www.regextester.com/ ## Workshop Day 4 ### First name and Last Name/Organization/Dept./Email | Name (first & last) | Organization | Dept. | Email | | ------------------------- | ------------ | ----- | --------------- | | (example) Jane Doe | UCSD | IT | jdoe1@ucsd.edu | |Tom Le|UCM||tle267@ucmerced.edu| |John Thompson |UC Merced |Cell & Molecular Biology |jthompson44@ucmerced.edu | |Sam Erickson |UC Merced |Physics |serickson3@ucmerced.edu |Dilawer Ali | UCM |Mehcanichanical Engineering |dali4@ucmerced.edu |Sarina Qin |UC Merced |Nat Sci |sqin@ucmerced.edu | |Douglas Zhang |UCSD |Chemistry and Biochemistry |doz023@ucsd.edu | |Kenan Chan |UCSD |SIO |kmc001@ucsd.edu | | Bruce Hamilton |UCSD |CMM|bah@health.ucsd.edu | |Jonathan Le |UCR |Mathematics |jle173@ucr.edu | |Amber Heidbrink |UCSD |Cell and Developmental Biology |aheidbrink@ucsd.edu | |Dayana Elizalde |UCR | |deliz002@ucr.edu | | Shang Su|U Toledo | Cell and Cancer Biology| Shang.su@utoledo.edu| |Christopher Gray |UCR |Computer Sciencee |cgray024@ucr.edu | |Oishee Misra |UCSD |Economics |omisra@ucsd.edu | |Ha Vu |UCSD |Economics |vha@ucsd.edu | |Michelle Wu |UCLA |Neuroscience |mwwu@ucla.edu | |Jay Chi | UCSB |ETS |jaychi@ucsb.edu | |Osika Tripathi |UCSD |PUblic Health |otripathi@health.ucsd.edu | |Kazuma Nagatsuka |UCSD |Robotics(Mechanical Engineering) |knagatsuka@ucsd.edu | | Melodi Frey| UCSD|CMM |mtastemel@health.ucsd.edu | |Matthew Falcone |UCB |Civil and Environmental Engineering | matthew_falcone@berkeley.edu| |Ivan Felix Rios | UCSD|Mathemathics & Economics | ifelixrios@ucsd.edu| |Brett Taylor |UCSD |Biomedical Sciences |b5taylor@ucsd.edu | | Agnieszka Pluta| UCLA| Psychology| agpluta@ucla.edu| |Jun Tan|UCSD |Economics |j4tan@ucsd.edu | Roberto Silva | UCSD | Scripps | rosilva@ucsd.edu | |Vishakha Malhotra|UCSF|Biostatistics and Epidemiology|vishakha.malhotra@ucsf.edu |Lillie Pennington|UC Merced|Life and Environmental Sciences|lpennington@ucmerced.edu |Alexander Frey|UCSD|Rady School of Management| alexander.frey@rady.ucsd.edu |Cherie Thompson|UCSD Library |Dexin Zhou|UCSD|Mathematics|dzhou@ucsd.edu| |Nicole Rosenberg|UCSD|Scripps|nrosenberg@ucsd.edu| |Mugen Blue|UCM|EECS|mblue3@ucmerced.edu| |Haley Potts|UCSD|Math & Economics|hpotts@ucsd.edu |Aleks Leszczynska|UCSD|Pediatrics|aleszczynska@ucsd.edu |Junxiao Gao|UCSF|Biostatistics and Epidemiology|Junxiao.Gao@ucsf.edu |Steven Krehel|UCSD|Economics|skrehel@ucsd.edu |Zhaoning (Johnny) Wang|UCSD|CMM|zhw063@health.ucsd.edu| |Daryl Han|UC Irvine|Student Center and Event Services|ddhan@uci.edu| |Josiah Piceno |UCM |MBSE |jpiceno3@ucmerced.edu | |Apisit Kaewsanit |UCSF|Epidemiology and Biostatistics|apisit.kaewsanit@ucsf.edu| |Jacob Ross|UCSD|anesthesiology|jaross@ucsd.edu| |Jay Colond|UCM|sociology|jcolond@ucmerced.edu| |Anshika Kandhway|UCM|Environmetal System|akandhway@ucmerced.edu| |Dilawer Ali|UCM|Mechanical Engineering|dali4@| |Bineh Ndefru|UCLA|Materials Science|bndefru@ucla.edu| |Mario Cuaya|UCR|Computer Science|mcuay001@ucr.edu| |Andrew Chan|UCSD|IGPP|andrewchan@ucsd.edu| |Andrew Gorin|UC Berkeley|Earth and Planetery Science|andrew_gorin@berkeley.edu| |Donald Zarate| UCR | Political Science and Psychology | dzara016@ucr.edu | |Jessica Wu-Woods|UCR|Microbiology|jwuw001@ucr.edu| ||||| ||||| ||||| ## Day 4 Exercises 1. **Copying a file** Instead of moving a file, you might want to copy a file (make a duplicate), for instance to make a backup before modifying a file. Just like the mv command, the cp command takes two arguments: the old name and the new name. How would you make a copy of the file gulliver.txt called gulliver-backup.txt? Try it! 2. **Renaming a directory** Renaming a directory works in the same way as renaming a file. Try using the mv command to rename the firstdir directory to backup. 3. **Moving a file into a directory** If the last argument you give to the mv command is a directory, not a file, the file given in the first argument will be moved to that directory. Try using the mv command to move the file gulliver-backup.txt into the backup folder. 4. **For loop exercise** Complete the blanks in the for loop below to print the name, first line, and last line of each text file in the current directory. ``` ___ file in *.txt ___ echo "_file" head -n 1 _____ ____ __ _ _____ ___ ``` 5. **Count, sort and print (faded example)** To count the total lines in every tsv file, sort the results and then print the first line of the file we use the following: wc -l *.tsv | sort -n | head -n 1 Now let’s change the scenario. We want to know the 10 files that contain the most words. Fill in the blanks below to count the words for each file, put them into order, and then make an output of the 10 files with the most words (Hint: The sort command sorts in ascending order by default). __ -w *.tsv | sort __ | ______ 6. **Counting number of files** Let’s make a different pipeline. You want to find out how many files and directories there are in the current directory. Try to see if you can pipe the output from ls into wc to find the answer. 7. **Counting the number of words** Check the manual for the wc command (either using man wc or wc --help) to see if you can find out what flag to use to print out the number of words (but not the number of lines and bytes). Try it with the .tsv files. If you have time, you can also try to sort the results by piping it to sort. And/or explore the other flags of wc. 8. **Case sensitive search in select files** Search for all case sensitive instances of a word you choose in the ‘America’ and ‘Africa’ .tsv files in this directory. Print your results to the shell. 9. **Count words (case sensitive)** Count all case sensitive instances of a word you choose in the ‘America’ and ‘Africa’ .tsv files in this directory. Print your results to the shell. 10. **Case insensitive search in select files (whole word)** Search for all case insensitive instances of that whole word in the ‘America’ and ‘Africa’ .tsv files in this directory. Print your results to a file results/hero-i.tsv. ## Day 4 Reflection Please enter how you will use the Unix Shell in your work or research here: 1. As a sysadmin, I use the shell everyday with SSH. Move and migrate data all the time with tools like rsync. Getting to the point where I prefer to manage files/folders with shell rather than macOS GUI. Many of the commands from the workshop were familiar, but defintely found some very helpful additional commands to help manage my systems more efficiently (i.e. CTRL-r). Thanks! ## Day 4 Survey Link to survey for today: https://forms.gle/5qgx8X6H3GRMacwD6 ## Day 4 Questions Please enter any questions not answered during live session here: 1. ### End Day 4

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully