Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Episode 6. Addition of a "cut" command to remove line numbers in history #318

Open
ckigenk opened this issue Jun 7, 2022 · 2 comments
Open

Comments

@ckigenk
Copy link

ckigenk commented Jun 7, 2022

In the section for documenting your work, the following code is run

history | tail -n 7 

The output is

 651  mkdir dc_workshop
 652  mkdir dc_workshop/docs
 653  mkdir dc_workshop/data
 654  mkdir dc_workshop/results
 655  ls -R
 656  history
 657  history | tail -n 7

The next step in the lesson is to redirect this output to an executable script so that the commands can be re-executed. However, the bash will return a command not found error because of the line numbers. This is a good opportunity to introduce the cut command by applying it to remove the line numbers. The command will be:

history | tail -n 7 | cut -d " " -f4-

The output

mkdir dc_workshop
mkdir dc_workshop/docs
mkdir dc_workshop/data
mkdir dc_workshop/results
ls -R
history
history | tail -n 7
history | tail -n 7 | cut -d " " -f 4-
@awnorowski
Copy link

I also noticed this issue.
If introducing another command would add too much content, another way to address this would be to edit the instructions to read:

Next, remove any lines of the history that are not relevant by navigating to those lines and using your delete key. Also remove the line numbers preceding each command. Save your file and close nano.

@p-j-smith
Copy link
Contributor

Hi @ckigenk and @awnorowski - apologies for not getting back to you sooner, and thanks for your suggestions!

cut is a very useful command, but the main course is already quite long and I'm not sure there's time to cover it properly. Also, the cut command is currently introduced in an optional extra lesson, so we should probably avoid duplicating too much content.

If introducing another command would add too much content, another way to address this would be to edit the instructions to read:

Next, remove any lines of the history that are not relevant by navigating to those lines and using your delete key. Also remove the line numbers preceding each command. Save your file and close nano.

I think this is a good compromise - it makes explicit what learners need to do to ensure their script will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants