Skip to content

Instantly share code, notes, and snippets.

@codejockie
Created November 29, 2017 08:20
Show Gist options
  • Select an option

  • Save codejockie/fe84b565ea382852a676e37c9d759f34 to your computer and use it in GitHub Desktop.

Select an option

Save codejockie/fe84b565ea382852a676e37c9d759f34 to your computer and use it in GitHub Desktop.
A basic shell script to that create directories, copy files, pipe input, execute commands etc
#! /bin/bash
cd ~ # moves to the home directory
mkdir "dev" # creates a new directory
cd "dev" # navigates to the newly created directory
mkdir "learning-bash"
cd "learning-bash"
touch ".gitignore" # creates a new file - .gitignore
touch "index.js" # creates a new file - index.js
cp file.doc newfile.doc # makes a copy of a file called file.doc in the current directory as newfile.doc
cp "index.js" /tmp # copies index.js file to tmp directory
ls # lists the content of the current directory
ls ~ # lists content of the home ddirectory
echo "Executes a command by printing this to the screen" # prints to stdout
ls | grep "index" # uses the commands ls and grep to list the files/directories in learning-bash that match the pattern "index".
echo 'node_modules/' >> .gitignore # copies the text node_modules to the .gitignore file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment