grep output to build folders with mkdir

G

Getut

Guest
I have grep output that give me lines of text that I want to use as subfolder names and create the folders with mkdir. The grep portion is working and giving me the output I need. It is basically a string that exists before the first and only comma in each line of a text file.

Code:
grep -o '^[^,]*' textfile

How can I iterate through those lines and build folders.. pseudo code below:

mkdir -p rootfolder/(line1 of grep output)
mkdir -p rootfolder/(line2 of grep output)

etc.
 


Pipe the output of grep to a while loop,


Code:
grep -o '^[^,]*' textfile|while read n;do mkdir "$n";done


Good luck ;)
 


Top