bash - Storing the first 4 characters of a filename into a variable -


This follwing code I'm writing is part of a script. Now, for the purposes of this script, I am assuming that ./src only has 1 file, so this loop should execute only once. Now, somewhere in the loop, I want to take the first 4 characters of $ F (filename) and store it in another variable. I know that there is a cut command, but I'm not sure how to use it here or here because I thought the cut was used for the content of the files but not the file itself.

  `ls. / Src` do HO $ F CD TMP F = "... / src / $ f" sh "$ f" done    

$ {string: position: length} $ string $ $ to extract $ x length letter extract

Example

  shortName = $ {f: 0} 4}   

Have fun!

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -