When run in the molecules directory, which ls command(s) will produce this output?
- Execute twice:
- View files and see how the > and >> differ in behavior
- What does >> do?
echo hello > testfile01.txt echo hello >> testfile02.txt
In our current directory, how would we find the 3 files which have the least number of lines?
- cd ../data
- cat animals.txt
- What does the following command output? (try to guess then check your answer)
cat animals.txt | head -n 5 | tail -n 3 | sort -r > final.txt
- Check that none of the samples searched for too many proteins
- cd ../molecules
- Use a for loop to print the name of the file and find the number of lines in each file ending in pdb
- cd ../north-pacific-gyre/2017-07-03
- print the name of the file for all files ending in A.txt and the name of an output file for goostats, stats-<filename>
- The syntax for goostats is
- run goostats on each file, printing the filename, and saving the output as stats-<filename>
goostats <input_filename> <output_filename>
Exercise #9: Make a nested loop
- For each species (cubane.pdb, methane.pdb) and temperature ( 0, 25, 50), make a file with the name <species>-<temperature>
- Create a program called do-stats.sh that takes as input a list of Nelle's files and prints the filename and then runs goostats, outputting the files to stats-<filename>
Exercise # 11
You and your friend, having just finished reading Little Women by Louisa May Alcott, are in an argument. Of the four sisters in the book, Jo, Meg, Beth, and Amy, your friend thinks that Jo was the most mentioned. You, however, are certain it was Amy. Luckily, you have a file LittleWomen.txt containing the full text of the novel (data-shell/writing/data/LittleWomen.txt). Using a for loop, how would you tabulate the number of times each of the four sisters is mentioned?
Hint: one solution might employ the commands grep and wc and a |, while another might utilize grepoptions. There is often more than one way to solve a programming task, so a particular solution is usually chosen based on a combination of yielding the correct result, elegance, readability, and speed.