Question about directories in Assignment 1

Question about directories in Assignment 1

by Mahnoor Hamid -
Number of replies: 7

Hello,

I had a question about directories in Assignment 1. Each student's data is in a separate directory, and I am having trouble getting my script to apply grep to all the directories branching from "data." If I am working in each student's directory separately, I can use grep, however when I am working from "data" I get an error saying something like "grep: Bert: Is a directory." I am thinking that each student's file should be a variable, however I am unsure what value to assign to the variable. I tried myvar="CI types" or myvar="names" but that did not work, and I am unsure how to proceed. I would appreciate if anyone had tips to troubleshoot this!

Mahnoor

In reply to Mahnoor Hamid

Re: Question about directories in Assignment 1

by Erik Spence -
Well, you've got two options. You can either move into the directory in question, and use grep there, or grep the files in that directory directly, without moving into the directory. Either approach is fine.

Remember how grep works: "grep WhatImLookingFor WhereImLookingForIt". If you do 'grep "CI types" Bert' grep will try to look for "CI types" in Bert, but Bert is not a file, so there's nothing to look for. You need to specify files for grep to search.
In reply to Erik Spence

Re: Question about directories in Assignment 1

by Leanna Lui -
Hi Dr. Spence,

Can one variable assigned to multiple strings using OR? e.g., fruit="apple" OR "banana" OR "orange"
In reply to Leanna Lui

Re: Question about directories in Assignment 1

by Erik Spence -
No. How would that work? A variable has a single value.
In reply to Erik Spence

Re: Question about directories in Assignment 1

by Stephanie Wong -
Hi Dr. Spence,

In the examples for tenth_smallest assignment, the output lists the directory, file name, and CI type. (i.e. Lawrence/Data0234:CI type: 6 )
However, my script only outputs file name and CI type (i.e. Data0234:CI type: 6). Is it necessary for the output to also include the directory?

Thank you!
In reply to Stephanie Wong

Re: Question about directories in Assignment 1

by Erik Spence -
No. Your output is satisfactory.
In reply to Erik Spence

Re: Question about directories in Assignment 1

by Anukrati Nigam -
Hello Dr. Spence,
In the tenth smallest assignment, what do we refer as the tenth smallest value? for eg.:
a) 1,1,2,2,2,3,3,3,4,6
b) 1,2,3,4,6,8,10,12,14,15
Will it be the subject with a) 6 despite the duplicate values or b) the subject with 15 given the distinct values in the data?
I'm likely overthinking it but wanted to confirm if I understood the statement "If there are multiple subjects with the same value, the first which is found should be output." correctly.

Thank you!
In reply to Anukrati Nigam

Re: Question about directories in Assignment 1

by Erik Spence -
Case a) is the one you want. The sentence you are referencing is a leftover from a previous version of this assignment, and doesn't really apply for this case.