I have files with names like file1.txt.txt.txt.txt and file2.txt.txt.txt.txt.txt............ (random infinite number of .txt exist).
how to truncate (mv) their names to ones with single .txt extension like file1.txt and file1.txt ? In other words, how to extract the filename upto first extension part?
But i have to do this for thousands of files in a directory so i cant use hardcoded filename. i will be using for loop for reading each file name. So, here how could i extract the "filename with first extension" out of "filename with infinite extensions"?
txs summer_cherry, here i dont know what is "number"..
Summer_cherry is just doing a echo of number,nothing to do with number that is not a variable.Whatever you do with echo that is excatly printed again.If you do not understand the code let me know i will tell you.
I know what " echo "number" " does and there's nothing hard to understand there. But his code expects again a "num".
I'm not sure if you read my post fully and again i repeat "how could i extract the "filename with first extension" out of "filename with infinite extensions"?" e.g., how to extract "file1.txt" from file1.txt.txt.txt..........? (no hardcoding of filenames with wild char pls..)
I am really curious to know the expression ${file%%.txt} .
Please can you explain it to me.
I was looking for a solution to extract the extrension of a file name. I wanted to split a file by line numbers but the unix split command splits the file with suffix is aa, ab, ac etc which I want to convert into 00, 01 etc and I was struggling to get the extension part.