-
fedev
-
RE: How to create folder name same as text file
-
what I wrote will work if you are running the command from the terminal and you are in the same folder as your test.txt file. Obviously the code could be used in a script and then you could pass some parameters to it (such as the location of the test.txt file). Also the command I wrote is to create a single level directory. So if you want to create two or more levels, it should be like this:
[code]
cat test.txt | xargs -I {} mkdir -p {}
[/code]
And if you want to make it a script, then it should be as:
[code]
#!/bin/bash
if [[ $# -ne 1 ]]
then
echo "This command requires one argument, the location of the test.txt file"
exit 1
fi
cat "$1" | xargs -I {} mkdir -p {}
[/code]
It could still be improved a lot but at least will give you an idea of where to start.
And, talking about where to start, it would be a good idea to check the following link out.
[url=http://tldp.org/LDP/abs/html/]Advance Bash Scripting Guide[/url]
-
24 Jun 10
what I wrote will work if you are running the command from the terminal and you are in the same folder as your test.txt file. Obviously the code could be used in a script and then you could pass some parameters to it (such as the location of the test.txt file). Also the command I wrote is to create a single level directory. So if you want to create two or more levels, it should be like this:
cat test.txt | xargs -I {} mkdir -p {}
And if you want to make it a script, then it should be as:
#!/bin/bash
if [[ $# -ne 1 ]]
then
echo "This command requires one argument, the location of the test.txt file"
exit 1
fi
cat "$1" | xargs -I {} mkdir -p {}
It could still be improved a lot but at least will give you an idea of where to start.
And, talking about where to start, it would be a good idea to check the following link out.
Advance Bash Scripting Guide