Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

substrings, brace expansion, sequence expressions

Let's say you have a set of files in a directory named like exp1eve1.txt exp1eve2.txt exp1eve3.txt exp1eve4.txt and you want to change the exp1 part to exp2 so they become exp2eve1.txt exp2eve2.txt ... There are so many ways to do the job. Using Substring Expansion one could do #!/bin/bash for i in exp1eve*.txt; do mv "$i" "${i:0:3}2${i:4:$((${#i}-3))}" done How does the substring expansion



This post first appeared on Unix Art, please read the originial post: here

Share the post

substrings, brace expansion, sequence expressions

×

Subscribe to Unix Art

Get updates delivered right to your inbox!

Thank you for your subscription

×