Example of excercise written in markdownĀ¶

Work with the bash shellĀ¶

Select and concatenate data filesĀ¶

In Bash,Ā *Ā is a wildcard, which matches zero or more characters. When the shell sees a wildcard, it expands the wildcard to create a list of matching filenames before running the command that was asked for. As an exception, if a wildcard expression does not match any file, Bash will pass the expression as an argument to the command as it is. For example typing ls *.pdf in the mountain_data/ directory (which does not contains any pdf files) results in an error message that there is no file called *.pdf.

Hereā€™s how the wildcard works in practice: *.txt matches annapurna-np.txt, chooyu-np.txt and every file that ends with ā€˜.txtā€™. On the other hand, n*.txt only matches nangaparbat-pl.txt because the ā€˜nā€™ at the front only matches filenames that begin with the letter ā€˜nā€™.

Exercise: Explore data files

Take a look at the contents of the mountain_data/ directory. Use ls and cat to inspect the names, file extensions and contents of the files. What patterns and information do you see? Tip: you can write your observations in comments section of the workshop website, and see what others observed. :)

Exercise: Select and concatenate data files

Right now, the data for each mountain in the mountain_data/ folder are each stored in separate files per mountain. That might be helpful for some applications, but we want a list of data in one .txt file called tallest-mountains.txt. How could we do that? Hint: We did this during the teaching session for all mountains in Nepal. The command to use starts with an ā€˜aā€™ and reminds me of my teenage yearsā€¦ :)

Exercise: add data to tallest-mountains.txt

Right now, the tallest-mountains.txt file contains geographic and population data for the 10 tallest mountains in the world. A good start, but there are many more cool mountains in the world! Add a few more mountains to the tallest-mountains.txt file using nano on the command line. Donā€™t forget to keep the same format as the rest of the data: name, lat, lon, height in meters, successful ascents(pre-2004), unsuccessful ascents(pre-2004). Hint: You can find a link to the data source in the mountain_data/README.md file.