shell script: check directory name and convert to lowercase
awk, bash, shell
Solution
Why not use:
#!/bin/bash
path=`pwd`
dirname=`basename $path | awk '{print tolower($0)}'`
Or if you want to do it as a one liner:
dirname=`pwd | xargs basename | awk '{print tolower($0)}'`
Problem
I would like my bash script to check the name of the directory where it is run. Something like: ``` #!/bin/bash path=eval 'pwd' dirname=eval 'basename $path' ``` But it doesn't work: I get ``` ./foo.sh: line 5: basename $path: command not found ``` How can I fix it? Also, once I get dirname to contain the correct dirname, I'd like to convert it to lowercase, to test it. I'm able to do this on the command line with awk: ``` echo $dirname | awk '{print tolower($0)}' ``` but how do I capture the return value into a variable?