简体   繁体   中英

Shell Scripting using array

How I can save multiple file name with absolute path in one file with runtime path provided by the user using shell scripting? Can we do it using array?

Are the files presently in an array? Like so:

$export file_arr=("file1" "file2")

and in your program:

outfile=out.txt

for item in "${file_arr[@]}"; do
    echo "$item" >> "$outfile"
done
#!/usr/bin/ksh
> input.txt
while true
do
    echo "Do you want to continue?"
    read choice
    case "$choice" in
      n|N) break;;
      y|Y) echo "Give The Absolute Path To Be Copied"
        read char
        echo $char >> input.txt
        ;;
      *) echo 'Response not valid';;
    esac
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM