Thread: Choosing a line from nl command
hi guys
trying write bash script , having trouble. want able search directory keyword, eg folder on desktop , search keyword readme. have been able , can pipe ls on folder nl command lists numbered files.
want able select number (eg 2) , display ls -l information of file selected. have idea on commands use this? stuck @ how select file has been listed nl command.
help!
hi , welcome forums!
please check out bashguide, bashfaq , bashpitfalls @ http://mywiki.wooledge.org/
read files in array:
print content of array:code:shopt -s nullglob cd path/to/dir arr=(*)
then like:code:for ((i=0; i<${#arr[@]}; i++)) printf '%d\t%s\n' $((i+1)) "${arr[i]}" done
of course have add error checks.code:read -r -p "select file: " nr ls -al "${arr[nr-1]}"
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] Choosing a line from nl command
Ubuntu
Comments
Post a Comment