Renaming files created by split

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












-2















I have output files from split called



shivi11aa
shivi11ab


(etc.)



How may I rename these existing files as



output_1
output_2


(etc.)



If I have 1000 files, the last one should be output_1000.










share|improve this question



















  • 1





    I edited the question based on some of your comments. You should have been able to do this yourself though, by pressing the edit link under the question. Please edit it further if it's not correct.

    – Kusalananda
    Jan 11 at 21:07











  • thanks,but n depends on the number of my ouput files

    – Shivani
    Jan 11 at 21:11






  • 1





    thank you very much and heartily thankfull

    – Shivani
    Jan 11 at 21:14






  • 1





    @Shivani Please also read What should I do when someone answers my question?. No need to hurry, though. Just take your time.

    – PerlDuck
    Jan 11 at 21:20






  • 1





    Also, for future reference, see this very nice writeup by Jeff, another user here: unix.meta.stackexchange.com/questions/5015

    – Kusalananda
    Jan 11 at 21:21















-2















I have output files from split called



shivi11aa
shivi11ab


(etc.)



How may I rename these existing files as



output_1
output_2


(etc.)



If I have 1000 files, the last one should be output_1000.










share|improve this question



















  • 1





    I edited the question based on some of your comments. You should have been able to do this yourself though, by pressing the edit link under the question. Please edit it further if it's not correct.

    – Kusalananda
    Jan 11 at 21:07











  • thanks,but n depends on the number of my ouput files

    – Shivani
    Jan 11 at 21:11






  • 1





    thank you very much and heartily thankfull

    – Shivani
    Jan 11 at 21:14






  • 1





    @Shivani Please also read What should I do when someone answers my question?. No need to hurry, though. Just take your time.

    – PerlDuck
    Jan 11 at 21:20






  • 1





    Also, for future reference, see this very nice writeup by Jeff, another user here: unix.meta.stackexchange.com/questions/5015

    – Kusalananda
    Jan 11 at 21:21













-2












-2








-2








I have output files from split called



shivi11aa
shivi11ab


(etc.)



How may I rename these existing files as



output_1
output_2


(etc.)



If I have 1000 files, the last one should be output_1000.










share|improve this question
















I have output files from split called



shivi11aa
shivi11ab


(etc.)



How may I rename these existing files as



output_1
output_2


(etc.)



If I have 1000 files, the last one should be output_1000.







linux shell-script






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 11 at 21:02









Kusalananda

127k16239393




127k16239393










asked Jan 11 at 20:14









Shivani Shivani

43




43







  • 1





    I edited the question based on some of your comments. You should have been able to do this yourself though, by pressing the edit link under the question. Please edit it further if it's not correct.

    – Kusalananda
    Jan 11 at 21:07











  • thanks,but n depends on the number of my ouput files

    – Shivani
    Jan 11 at 21:11






  • 1





    thank you very much and heartily thankfull

    – Shivani
    Jan 11 at 21:14






  • 1





    @Shivani Please also read What should I do when someone answers my question?. No need to hurry, though. Just take your time.

    – PerlDuck
    Jan 11 at 21:20






  • 1





    Also, for future reference, see this very nice writeup by Jeff, another user here: unix.meta.stackexchange.com/questions/5015

    – Kusalananda
    Jan 11 at 21:21












  • 1





    I edited the question based on some of your comments. You should have been able to do this yourself though, by pressing the edit link under the question. Please edit it further if it's not correct.

    – Kusalananda
    Jan 11 at 21:07











  • thanks,but n depends on the number of my ouput files

    – Shivani
    Jan 11 at 21:11






  • 1





    thank you very much and heartily thankfull

    – Shivani
    Jan 11 at 21:14






  • 1





    @Shivani Please also read What should I do when someone answers my question?. No need to hurry, though. Just take your time.

    – PerlDuck
    Jan 11 at 21:20






  • 1





    Also, for future reference, see this very nice writeup by Jeff, another user here: unix.meta.stackexchange.com/questions/5015

    – Kusalananda
    Jan 11 at 21:21







1




1





I edited the question based on some of your comments. You should have been able to do this yourself though, by pressing the edit link under the question. Please edit it further if it's not correct.

– Kusalananda
Jan 11 at 21:07





I edited the question based on some of your comments. You should have been able to do this yourself though, by pressing the edit link under the question. Please edit it further if it's not correct.

– Kusalananda
Jan 11 at 21:07













thanks,but n depends on the number of my ouput files

– Shivani
Jan 11 at 21:11





thanks,but n depends on the number of my ouput files

– Shivani
Jan 11 at 21:11




1




1





thank you very much and heartily thankfull

– Shivani
Jan 11 at 21:14





thank you very much and heartily thankfull

– Shivani
Jan 11 at 21:14




1




1





@Shivani Please also read What should I do when someone answers my question?. No need to hurry, though. Just take your time.

– PerlDuck
Jan 11 at 21:20





@Shivani Please also read What should I do when someone answers my question?. No need to hurry, though. Just take your time.

– PerlDuck
Jan 11 at 21:20




1




1





Also, for future reference, see this very nice writeup by Jeff, another user here: unix.meta.stackexchange.com/questions/5015

– Kusalananda
Jan 11 at 21:21





Also, for future reference, see this very nice writeup by Jeff, another user here: unix.meta.stackexchange.com/questions/5015

– Kusalananda
Jan 11 at 21:21










1 Answer
1






active

oldest

votes


















5














n=0
for filename in shivi11*; do
n=$(( n + 1 ))
mv -i "$filename" "output_$n"
done


... where shivi11* is a pattern that must match all files that you'd like to rename (and nothing else).



Back up your data and test this.




Answer to the original question (before editing it):



If you by "split" mean the split utility, then you may invoke the utility like this to get what you want (this assumes GNU split and that you'd like to split the file file into 20 KB bits):



split -b 20k -a 1 --numeric-suffixes=1 file output_


This creates output_1, output_2 etc.



Note that since we restrict the suffix length to a single character with -a 1, this would not be able to split into more than 9 files. Using e.g. -a 2 would create files named output_01, output_02 etc. up to and including output_99, but not output_100.



The --numeric-suffixes=1 option is a GNU split-specific option that selects numeric suffixes starting at the given number (instead of at 0 as using -d would do). Normally, split creates files with alphabetic suffixes.






share|improve this answer

























  • I JUST NEED TO RENAME FILES LIKE ABC.TXT?? TO OUTPUT_1 AND HOW TO DO FOR 5 OUTPUT FILES LIKE THIS

    – Shivani
    Jan 11 at 20:40






  • 2





    @Shivani No need to shout. Calmly make your question unambiguous instead. If you don't use the split utility, then don't mention it (which you do now with "the output from split"). Instead tell us what you have and what you want, and someone may be interested enough to answer.

    – Kusalananda
    Jan 11 at 20:43












  • MY QUESTION IS TO RENAME THE MULTIPLE FILES LIKE ABC.TXT TO OUTPUT_1,OUTPUT_2 AND SO ON IF I HAVE FIVE OUTPUT FILES,,PLEASE SHARE HOW TO USE MOVE COMMAND BY USING FOR LOOP IN THIS

    – Shivani
    Jan 11 at 20:45






  • 4





    @Shivani Unstick you CapsLock key and update your question. Also note that we are volunteers and that this is not a code-writing service.

    – Kusalananda
    Jan 11 at 20:47












  • my question is to rename the multiple files like abc.txt to ouput_1,output_2 and so on if i have five output files.How to use for loop for renaming.Actually i already split the files according to lines and now i want to rename them

    – Shivani
    Jan 11 at 20:49










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494010%2frenaming-files-created-by-split%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














n=0
for filename in shivi11*; do
n=$(( n + 1 ))
mv -i "$filename" "output_$n"
done


... where shivi11* is a pattern that must match all files that you'd like to rename (and nothing else).



Back up your data and test this.




Answer to the original question (before editing it):



If you by "split" mean the split utility, then you may invoke the utility like this to get what you want (this assumes GNU split and that you'd like to split the file file into 20 KB bits):



split -b 20k -a 1 --numeric-suffixes=1 file output_


This creates output_1, output_2 etc.



Note that since we restrict the suffix length to a single character with -a 1, this would not be able to split into more than 9 files. Using e.g. -a 2 would create files named output_01, output_02 etc. up to and including output_99, but not output_100.



The --numeric-suffixes=1 option is a GNU split-specific option that selects numeric suffixes starting at the given number (instead of at 0 as using -d would do). Normally, split creates files with alphabetic suffixes.






share|improve this answer

























  • I JUST NEED TO RENAME FILES LIKE ABC.TXT?? TO OUTPUT_1 AND HOW TO DO FOR 5 OUTPUT FILES LIKE THIS

    – Shivani
    Jan 11 at 20:40






  • 2





    @Shivani No need to shout. Calmly make your question unambiguous instead. If you don't use the split utility, then don't mention it (which you do now with "the output from split"). Instead tell us what you have and what you want, and someone may be interested enough to answer.

    – Kusalananda
    Jan 11 at 20:43












  • MY QUESTION IS TO RENAME THE MULTIPLE FILES LIKE ABC.TXT TO OUTPUT_1,OUTPUT_2 AND SO ON IF I HAVE FIVE OUTPUT FILES,,PLEASE SHARE HOW TO USE MOVE COMMAND BY USING FOR LOOP IN THIS

    – Shivani
    Jan 11 at 20:45






  • 4





    @Shivani Unstick you CapsLock key and update your question. Also note that we are volunteers and that this is not a code-writing service.

    – Kusalananda
    Jan 11 at 20:47












  • my question is to rename the multiple files like abc.txt to ouput_1,output_2 and so on if i have five output files.How to use for loop for renaming.Actually i already split the files according to lines and now i want to rename them

    – Shivani
    Jan 11 at 20:49















5














n=0
for filename in shivi11*; do
n=$(( n + 1 ))
mv -i "$filename" "output_$n"
done


... where shivi11* is a pattern that must match all files that you'd like to rename (and nothing else).



Back up your data and test this.




Answer to the original question (before editing it):



If you by "split" mean the split utility, then you may invoke the utility like this to get what you want (this assumes GNU split and that you'd like to split the file file into 20 KB bits):



split -b 20k -a 1 --numeric-suffixes=1 file output_


This creates output_1, output_2 etc.



Note that since we restrict the suffix length to a single character with -a 1, this would not be able to split into more than 9 files. Using e.g. -a 2 would create files named output_01, output_02 etc. up to and including output_99, but not output_100.



The --numeric-suffixes=1 option is a GNU split-specific option that selects numeric suffixes starting at the given number (instead of at 0 as using -d would do). Normally, split creates files with alphabetic suffixes.






share|improve this answer

























  • I JUST NEED TO RENAME FILES LIKE ABC.TXT?? TO OUTPUT_1 AND HOW TO DO FOR 5 OUTPUT FILES LIKE THIS

    – Shivani
    Jan 11 at 20:40






  • 2





    @Shivani No need to shout. Calmly make your question unambiguous instead. If you don't use the split utility, then don't mention it (which you do now with "the output from split"). Instead tell us what you have and what you want, and someone may be interested enough to answer.

    – Kusalananda
    Jan 11 at 20:43












  • MY QUESTION IS TO RENAME THE MULTIPLE FILES LIKE ABC.TXT TO OUTPUT_1,OUTPUT_2 AND SO ON IF I HAVE FIVE OUTPUT FILES,,PLEASE SHARE HOW TO USE MOVE COMMAND BY USING FOR LOOP IN THIS

    – Shivani
    Jan 11 at 20:45






  • 4





    @Shivani Unstick you CapsLock key and update your question. Also note that we are volunteers and that this is not a code-writing service.

    – Kusalananda
    Jan 11 at 20:47












  • my question is to rename the multiple files like abc.txt to ouput_1,output_2 and so on if i have five output files.How to use for loop for renaming.Actually i already split the files according to lines and now i want to rename them

    – Shivani
    Jan 11 at 20:49













5












5








5







n=0
for filename in shivi11*; do
n=$(( n + 1 ))
mv -i "$filename" "output_$n"
done


... where shivi11* is a pattern that must match all files that you'd like to rename (and nothing else).



Back up your data and test this.




Answer to the original question (before editing it):



If you by "split" mean the split utility, then you may invoke the utility like this to get what you want (this assumes GNU split and that you'd like to split the file file into 20 KB bits):



split -b 20k -a 1 --numeric-suffixes=1 file output_


This creates output_1, output_2 etc.



Note that since we restrict the suffix length to a single character with -a 1, this would not be able to split into more than 9 files. Using e.g. -a 2 would create files named output_01, output_02 etc. up to and including output_99, but not output_100.



The --numeric-suffixes=1 option is a GNU split-specific option that selects numeric suffixes starting at the given number (instead of at 0 as using -d would do). Normally, split creates files with alphabetic suffixes.






share|improve this answer















n=0
for filename in shivi11*; do
n=$(( n + 1 ))
mv -i "$filename" "output_$n"
done


... where shivi11* is a pattern that must match all files that you'd like to rename (and nothing else).



Back up your data and test this.




Answer to the original question (before editing it):



If you by "split" mean the split utility, then you may invoke the utility like this to get what you want (this assumes GNU split and that you'd like to split the file file into 20 KB bits):



split -b 20k -a 1 --numeric-suffixes=1 file output_


This creates output_1, output_2 etc.



Note that since we restrict the suffix length to a single character with -a 1, this would not be able to split into more than 9 files. Using e.g. -a 2 would create files named output_01, output_02 etc. up to and including output_99, but not output_100.



The --numeric-suffixes=1 option is a GNU split-specific option that selects numeric suffixes starting at the given number (instead of at 0 as using -d would do). Normally, split creates files with alphabetic suffixes.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 11 at 21:14

























answered Jan 11 at 20:36









KusalanandaKusalananda

127k16239393




127k16239393












  • I JUST NEED TO RENAME FILES LIKE ABC.TXT?? TO OUTPUT_1 AND HOW TO DO FOR 5 OUTPUT FILES LIKE THIS

    – Shivani
    Jan 11 at 20:40






  • 2





    @Shivani No need to shout. Calmly make your question unambiguous instead. If you don't use the split utility, then don't mention it (which you do now with "the output from split"). Instead tell us what you have and what you want, and someone may be interested enough to answer.

    – Kusalananda
    Jan 11 at 20:43












  • MY QUESTION IS TO RENAME THE MULTIPLE FILES LIKE ABC.TXT TO OUTPUT_1,OUTPUT_2 AND SO ON IF I HAVE FIVE OUTPUT FILES,,PLEASE SHARE HOW TO USE MOVE COMMAND BY USING FOR LOOP IN THIS

    – Shivani
    Jan 11 at 20:45






  • 4





    @Shivani Unstick you CapsLock key and update your question. Also note that we are volunteers and that this is not a code-writing service.

    – Kusalananda
    Jan 11 at 20:47












  • my question is to rename the multiple files like abc.txt to ouput_1,output_2 and so on if i have five output files.How to use for loop for renaming.Actually i already split the files according to lines and now i want to rename them

    – Shivani
    Jan 11 at 20:49

















  • I JUST NEED TO RENAME FILES LIKE ABC.TXT?? TO OUTPUT_1 AND HOW TO DO FOR 5 OUTPUT FILES LIKE THIS

    – Shivani
    Jan 11 at 20:40






  • 2





    @Shivani No need to shout. Calmly make your question unambiguous instead. If you don't use the split utility, then don't mention it (which you do now with "the output from split"). Instead tell us what you have and what you want, and someone may be interested enough to answer.

    – Kusalananda
    Jan 11 at 20:43












  • MY QUESTION IS TO RENAME THE MULTIPLE FILES LIKE ABC.TXT TO OUTPUT_1,OUTPUT_2 AND SO ON IF I HAVE FIVE OUTPUT FILES,,PLEASE SHARE HOW TO USE MOVE COMMAND BY USING FOR LOOP IN THIS

    – Shivani
    Jan 11 at 20:45






  • 4





    @Shivani Unstick you CapsLock key and update your question. Also note that we are volunteers and that this is not a code-writing service.

    – Kusalananda
    Jan 11 at 20:47












  • my question is to rename the multiple files like abc.txt to ouput_1,output_2 and so on if i have five output files.How to use for loop for renaming.Actually i already split the files according to lines and now i want to rename them

    – Shivani
    Jan 11 at 20:49
















I JUST NEED TO RENAME FILES LIKE ABC.TXT?? TO OUTPUT_1 AND HOW TO DO FOR 5 OUTPUT FILES LIKE THIS

– Shivani
Jan 11 at 20:40





I JUST NEED TO RENAME FILES LIKE ABC.TXT?? TO OUTPUT_1 AND HOW TO DO FOR 5 OUTPUT FILES LIKE THIS

– Shivani
Jan 11 at 20:40




2




2





@Shivani No need to shout. Calmly make your question unambiguous instead. If you don't use the split utility, then don't mention it (which you do now with "the output from split"). Instead tell us what you have and what you want, and someone may be interested enough to answer.

– Kusalananda
Jan 11 at 20:43






@Shivani No need to shout. Calmly make your question unambiguous instead. If you don't use the split utility, then don't mention it (which you do now with "the output from split"). Instead tell us what you have and what you want, and someone may be interested enough to answer.

– Kusalananda
Jan 11 at 20:43














MY QUESTION IS TO RENAME THE MULTIPLE FILES LIKE ABC.TXT TO OUTPUT_1,OUTPUT_2 AND SO ON IF I HAVE FIVE OUTPUT FILES,,PLEASE SHARE HOW TO USE MOVE COMMAND BY USING FOR LOOP IN THIS

– Shivani
Jan 11 at 20:45





MY QUESTION IS TO RENAME THE MULTIPLE FILES LIKE ABC.TXT TO OUTPUT_1,OUTPUT_2 AND SO ON IF I HAVE FIVE OUTPUT FILES,,PLEASE SHARE HOW TO USE MOVE COMMAND BY USING FOR LOOP IN THIS

– Shivani
Jan 11 at 20:45




4




4





@Shivani Unstick you CapsLock key and update your question. Also note that we are volunteers and that this is not a code-writing service.

– Kusalananda
Jan 11 at 20:47






@Shivani Unstick you CapsLock key and update your question. Also note that we are volunteers and that this is not a code-writing service.

– Kusalananda
Jan 11 at 20:47














my question is to rename the multiple files like abc.txt to ouput_1,output_2 and so on if i have five output files.How to use for loop for renaming.Actually i already split the files according to lines and now i want to rename them

– Shivani
Jan 11 at 20:49





my question is to rename the multiple files like abc.txt to ouput_1,output_2 and so on if i have five output files.How to use for loop for renaming.Actually i already split the files according to lines and now i want to rename them

– Shivani
Jan 11 at 20:49

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494010%2frenaming-files-created-by-split%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?