简体   繁体   中英

Update last character of string using shell script

I am new to shell script and I want to update the last character of the string /dev/sda to next alphabet letter and loop through the count provided then write it into a file using shell script. could someone help me on this?

For Example: If Count is 10, so I want to loop 10 times to update the string and write in a file in next line with the updated string.

Sample File: myfile.txt

/dev/sda
/dev/sdb
/dev/sdc
/dev/sdd .... and so on

Generate all the possibilities, select only those you want.

printf '%s\n' /dev/sd{a..z} | head -n"$count"

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