Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/458115781956763648
edited tags
Source Link
Hauke Laging
  • 94.8k
  • 21
  • 132
  • 185

I'm trying to write a bash shell script that will read the data from a given (as an argument) file, and for each row in the file, make a sub-directory under the given (as an argument) directory.

The script is named studentDir and the input file is named studentInfo.txt.
Here is two lines from it:

Sara Smith Freshman Marketing   James Lucas Junior Engineering 

On the command line the user would write the script name, the txt file name, and the directory where the new directories should be stored. I think it would be like this:

$ studentDir studentInfo.txt . 

Which will create the sub-directories in the current directory.

The directories should be named LLLLFF.
For example:

SmitSa LucaJa 

(The other info from the input file is not needed)

I think to get the names I would use:

DIRNAME=$(cut -d' ' -f2 | cut -c1-4 ; cut -d' ' -f1 | cut -c1-2) mkdir "$DIRNAME" 

But I'm not sure what command would create a directory for each row, and how I could do it recursively for each one.

I'm trying to write a bash shell script that will read the data from a given (as an argument) file, and for each row in the file, make a sub-directory under the given (as an argument) directory.

The script is named studentDir and the input file is named studentInfo.txt.
Here is two lines from it:

Sara Smith Freshman Marketing   James Lucas Junior Engineering 

On the command line the user would write the script name, the txt file name, and the directory where the new directories should be stored. I think it would be like this:

$ studentDir studentInfo.txt . 

Which will create the sub-directories in the current directory.

The directories should be named LLLLFF.
For example:

SmitSa LucaJa 

(The other info from the input file is not needed)

I think to get the names I would use:

DIRNAME=$(cut -d' ' -f2 | cut -c1-4 ; cut -d' ' -f1 | cut -c1-2) mkdir "$DIRNAME" 

But I'm not sure what command would create a directory for each row, and how I could do it recursively for each one.

I'm trying to write a bash shell script that will read the data from a given (as an argument) file, and for each row in the file, make a sub-directory under the given (as an argument) directory.

The script is named studentDir and the input file is named studentInfo.txt.
Here is two lines from it:

Sara Smith Freshman Marketing James Lucas Junior Engineering 

On the command line the user would write the script name, the txt file name, and the directory where the new directories should be stored. I think it would be like this:

$ studentDir studentInfo.txt . 

Which will create the sub-directories in the current directory.

The directories should be named LLLLFF.
For example:

SmitSa LucaJa 

(The other info from the input file is not needed)

I think to get the names I would use:

DIRNAME=$(cut -d' ' -f2 | cut -c1-4 ; cut -d' ' -f1 | cut -c1-2) mkdir "$DIRNAME" 

But I'm not sure what command would create a directory for each row, and how I could do it recursively for each one.

added 10 characters in body
Source Link
phemmer
  • 73.9k
  • 21
  • 199
  • 231

I'm trying to write a bash shell script that will read the data from a given (as an argument) file, and for each row in the file, make a sub-directory under the given (as an argument) directory.

The script is named studentDir and the input file is named studentInfo.txt.
Here is two lines from it:

Sara Smith Freshman Marketing James Lucas Junior Engineering 

On the command line the user would write the script name, the txt file name, and the directory where the new directories should be stored. I think it would be like this:

$ studentDir studentInfo.txt . 

Which will create the sub-directories in the current directory.

The directories should be named LLLLFF.
For example:

SmitSa LucaJa 

(The other info from the input file is not needed)

I think to get the names I would use: DIRNAME=$(cut -d' ' -f2 | cut -c1-4 ; cut -d' ' -f1 | cut -c1-2) mkdir "$DIRNAME"

DIRNAME=$(cut -d' ' -f2 | cut -c1-4 ; cut -d' ' -f1 | cut -c1-2) mkdir "$DIRNAME" 

But I'm not sure what command would create a directory for each row, and how I could do it recursively for each one.

I'm trying to write a bash shell script that will read the data from a given (as an argument) file, and for each row in the file, make a sub-directory under the given (as an argument) directory.

The script is named studentDir and the input file is named studentInfo.txt.
Here is two lines from it:

Sara Smith Freshman Marketing James Lucas Junior Engineering 

On the command line the user would write the script name, the txt file name, and the directory where the new directories should be stored. I think it would be like this:

$ studentDir studentInfo.txt . 

Which will create the sub-directories in the current directory.

The directories should be named LLLLFF.
For example:

SmitSa LucaJa 

(The other info from the input file is not needed)

I think to get the names I would use: DIRNAME=$(cut -d' ' -f2 | cut -c1-4 ; cut -d' ' -f1 | cut -c1-2) mkdir "$DIRNAME"

But I'm not sure what command would create a directory for each row, and how I could do it recursively for each one.

I'm trying to write a bash shell script that will read the data from a given (as an argument) file, and for each row in the file, make a sub-directory under the given (as an argument) directory.

The script is named studentDir and the input file is named studentInfo.txt.
Here is two lines from it:

Sara Smith Freshman Marketing James Lucas Junior Engineering 

On the command line the user would write the script name, the txt file name, and the directory where the new directories should be stored. I think it would be like this:

$ studentDir studentInfo.txt . 

Which will create the sub-directories in the current directory.

The directories should be named LLLLFF.
For example:

SmitSa LucaJa 

(The other info from the input file is not needed)

I think to get the names I would use:

DIRNAME=$(cut -d' ' -f2 | cut -c1-4 ; cut -d' ' -f1 | cut -c1-2) mkdir "$DIRNAME" 

But I'm not sure what command would create a directory for each row, and how I could do it recursively for each one.

Re-did the directory naming
Source Link
Lacey
  • 69
  • 2
  • 4
Loading
deleted 16 characters in body
Source Link
phemmer
  • 73.9k
  • 21
  • 199
  • 231
Loading
deleted 18 characters in body
Source Link
Hauke Laging
  • 94.8k
  • 21
  • 132
  • 185
Loading
Source Link
Lacey
  • 69
  • 2
  • 4
Loading