Skip to main content

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:
code:
shopt -s nullglob  cd path/to/dir  arr=(*)
print content of array:
code:
for ((i=0; i<${#arr[@]}; i++))       printf '%d\t%s\n' $((i+1)) "${arr[i]}"  done
then like:
code:
read -r -p "select file: " nr  ls -al "${arr[nr-1]}"
of course have add error checks.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] Choosing a line from nl command


Ubuntu

Comments

Popular posts from this blog

Warning, the Safe Path is not accessible vm3 - Joomla! Forum - community, help and support

uppercase letters in url - Joomla! Forum - community, help and support

Joomla! Update is not offering Joomla 3 - Joomla! Forum - community, help and support