bash - Immediate subdirectory of a given argument or the current directory if no argument is given -
everyone. quick question pretty embarrassing. how pass directory argument bash shell script , how written within actual script? script supposed work in current directory if given argument (another directory), should work given parameters. i've checked around internet last 3 hours , keep finding complicated solutions end confusing me. question follows:
the script should list disk storage occupied each immediate subdirectory of given argument or current directory (if no argument given) subdirectory names sorted alphabetically. also, list name of subdirectory highest disk usage along storage size.
just need first sentence. have far. i've done of program directory issue has me stumped.
#!/bin/bash ls -xl > file.txt cut -d ' ' -f 5- file.txt > file2.txt echo "list in alpha order: " cat file2.txt echo "largest dir is: " du -ab | head -1
any assistance appreciated, please.
searchdir="${1:-$pwd}"
Comments
Post a Comment