Skip to content

Instantly share code, notes, and snippets.

View telatin's full-sized avatar
:octocat:

Andrea Telatin telatin

:octocat:
View GitHub Profile
@telatin
telatin / 0_reuse_code.js
Created November 6, 2015 14:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@telatin
telatin / hello.sh
Created March 2, 2018 09:35
Bash intro
#!/bin/bash
# This script prints your city name and the CURRENT date
# We can create a variable CITY
CITY="Norwich"
# The variable DATE will be created with the output of the 'date' command
DATE=$(date +"%Y-%m-%d")
# Finally, we print a string using the variables we declared.
@telatin
telatin / hello_world.sh
Created March 2, 2018 09:37
First script "Hello world"
#!/bin/bash
# This script prints a nice message. Note that text after a "#" is ignored
# and you can use this to add comments to your scripts. Well, you SHOULD.
echo "Hello, world!"
@telatin
telatin / count_files.sh
Created March 2, 2018 10:52
Simple demo script counting files and directories in current position
#!/bin/bash
# A simple script counting files in "current" directory.
echo -n "You are working in: "
pwd
echo -n "Files in your current directory: "
ls | wc -l
#!/bin/bash
# A for loop iterates a set of command (between "do" and "done"),
# one time for each of the item in a list. In this example we make
# a list of three names
for FirstName in Andy Brandy Candy;
do
echo "Hello $FirstName!"
# You can type many commands here!
#!/bin/bash
# A first example of 'for loop' to iterate a set of commands over a list of files
SamFilesCount=$(ls *.sam | wc -l);
echo "In this directory you have ${SamFilesCount}"
for SamFile in *.sam
do
echo -n "Converting ${SamFile}... "
#!/bin/bash
# A script listing all .sam files in a directory, proposing the name
# for their respective .bam file.
for File in *.sam
do
echo "SAM File: $File"
echo "Possible BAM file: ${File/.sam/.bam}"
done
#!/bin/bash
# A first example of 'for loop' to iterate a set of commands over a list of files
SamFilesCount=$(ls *.sam | wc -l);
echo "In this directory you have ${SamFilesCount}"
# Loop throught all .sam files (note: won't work if no .sam files are present!)
for SamFile in *.sam
do
#!/bin/bash
# A first example of 'for loop' to iterate a set of commands over a list of files
SamFilesCount=$(ls *.sam | wc -l);
echo "In this directory you have ${SamFilesCount}"
# Loop throught all .sam files (note: won't work if no .sam files are present!)
for SamFile in *.sam
do
#!/bin/bash
# A first example of 'for loop' to iterate a set of commands over a list of files
SamFilesCount=$(ls *.sam | wc -l);
if [[ $SamFilesCount -eq 0 ]]
then
echo " Warning: there are no .sam files to process in this directory!"
exit;
fi