Part 2. Simple pipeline (5 points)
For several subsequent parts of this lab, you’re going to need to run the scripts you write on a large code base. We’re going to use the source code for the Linux kernel. You’re going to write a one-line shell script that downloads and decompresses the source code.
Your task
Write a one-line script that will uses curl
to download the compressed Linux
source code and pipes it to tar
which extracts the source code into the
current directory. The Linux source code is available at this URL.
https://github.com/torvalds/linux/archive/refs/tags/v6.4.tar.gz
Your command should be structured as follow.
$ curl ARGS | tar ARGS
After you run the command, you should have a new directory named linux-6.4
which contains the source code to version 6.4 of Linux. Do not commit the
Linux source code to your assignment repository.
Write the pipeline command you come up with in a file named README
.
Normally, a README
provides information about a project. GitHub will display
the contents of your README
when you visit the web page for your repository
(after you have pushed the README
to GitHub). You’ll use this same file
several times to record the commands you come up with.
- If you run
curl https://github.com/torvalds/linux/archive/refs/tags/v6.4.tar.gz
with no other options, no output is printed. That’s because GitHub, like many websites will redirect the browser to different URLs. The way this works technically is to use a redirection HTTP status with aLocation
header. Search thecurl
man page to figure out which option to use to getcurl
to follow the redirection specified in theLocation
header. - The
tar
command, like many (but sadly not all) command-line utilities that operates on files, will accept a single-
as the name of the file to mean read fromstdin
rather than reading from the file (and for output, write tostdout
rather than writing to a file).