Need to trim the names of file names












2















enter image description hereI have files in UNIX directory which have a unique number starting with, i have to remove the unique id followed by '-' from the file name and need to have regular file.



Example: 32456113-report.pdf



Required File name in the database: report.pdf



I have file names of all kind of extensions .pdf, .doc, .xls, .txt but have the same number in the front.



I am using winscp to test or view the data and i am running a shell script by registering it as a host concurrent program in oracle apps.










share|improve this question

























  • Not sure I understand where the database fits in. Are you using another language to interact with a database?

    – Josh Berry
    Jul 2 '13 at 19:57
















2















enter image description hereI have files in UNIX directory which have a unique number starting with, i have to remove the unique id followed by '-' from the file name and need to have regular file.



Example: 32456113-report.pdf



Required File name in the database: report.pdf



I have file names of all kind of extensions .pdf, .doc, .xls, .txt but have the same number in the front.



I am using winscp to test or view the data and i am running a shell script by registering it as a host concurrent program in oracle apps.










share|improve this question

























  • Not sure I understand where the database fits in. Are you using another language to interact with a database?

    – Josh Berry
    Jul 2 '13 at 19:57














2












2








2








enter image description hereI have files in UNIX directory which have a unique number starting with, i have to remove the unique id followed by '-' from the file name and need to have regular file.



Example: 32456113-report.pdf



Required File name in the database: report.pdf



I have file names of all kind of extensions .pdf, .doc, .xls, .txt but have the same number in the front.



I am using winscp to test or view the data and i am running a shell script by registering it as a host concurrent program in oracle apps.










share|improve this question
















enter image description hereI have files in UNIX directory which have a unique number starting with, i have to remove the unique id followed by '-' from the file name and need to have regular file.



Example: 32456113-report.pdf



Required File name in the database: report.pdf



I have file names of all kind of extensions .pdf, .doc, .xls, .txt but have the same number in the front.



I am using winscp to test or view the data and i am running a shell script by registering it as a host concurrent program in oracle apps.







rename filenames ksh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '18 at 20:42









Rui F Ribeiro

39.4k1479131




39.4k1479131










asked Jul 2 '13 at 19:13









samsam

2139




2139













  • Not sure I understand where the database fits in. Are you using another language to interact with a database?

    – Josh Berry
    Jul 2 '13 at 19:57



















  • Not sure I understand where the database fits in. Are you using another language to interact with a database?

    – Josh Berry
    Jul 2 '13 at 19:57

















Not sure I understand where the database fits in. Are you using another language to interact with a database?

– Josh Berry
Jul 2 '13 at 19:57





Not sure I understand where the database fits in. Are you using another language to interact with a database?

– Josh Berry
Jul 2 '13 at 19:57










4 Answers
4






active

oldest

votes


















3














for f in *; do 
regular="${f#*-}"
echo "$f => $regular"
done


This parameter expansion (${f#*-}) removes, from the start of the variable's value, the shortest string that ends with a hyphen (see manual). So:



$ f=32456113-summary-report.doc
$ echo "$f => ${f#*-}"
32456113-summary-report.doc => summary-report.doc





share|improve this answer
























  • mv: cannot rename /tmp/34178248 to /tmp/34178248//34178248: Invalid argument /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3: bad substitution /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3 Program exited with status 1

    – sam
    Jul 2 '13 at 20:41











  • This code might not work for ksh, which is what @sam is using.

    – user26112
    Jul 2 '13 at 20:42













  • This code does work in ksh, that's where I tested it. @sam, please show what you're actually running, edit your question with more details please.

    – glenn jackman
    Jul 2 '13 at 20:45













  • mv -- "34178248-2640006.pdf" "${34178248-2640006.pdf}" when i use this i got the desired result, can i automate the process for all the files in the directory

    – sam
    Jul 2 '13 at 23:39



















1














Not entirely sure I understand what you are trying to do, but I believe a simple bash script as follows would work



for f in * ; do mv "$f" "$(echo "$f" | cut -d- -f2)"; done


If you don't like the echo to cut nonsense, I can look up the string rules in bash for you.






share|improve this answer


























  • I fixed up your code a bit to include more quotation marks. Also, don't parse ls output.

    – user26112
    Jul 2 '13 at 20:09











  • :) Thanks! I should have known better than parsing ls, but was too blinded by not immediately knowing the string rules of bash.

    – Josh Berry
    Jul 2 '13 at 20:15











  • Apparently the original poster is using ksh.

    – user26112
    Jul 2 '13 at 20:17











  • Thanks for your reply..... my file name is changed but it was like this $(echo 34178248-BPI_TAX_EX--.pdf | cut -d- -f2). Any suggestion, i really appreciate for your time

    – sam
    Jul 2 '13 at 20:31











  • You can use cut -d- -f2- instead.

    – user26112
    Jul 2 '13 at 20:35



















1














You can use perl-rename.



perl-rename 's/[0-9]*-//' <files>


Depending your OS/distro, this utility may be called rename. To be safe, use the -n flag with perl-rename to do a dry run before actually renaming any files.






share|improve this answer


























  • ksh[6]: syntax error at line 6 : ';' unexpected.... i got this when i run the above command in winscp

    – sam
    Jul 2 '13 at 19:29











  • and Thanks for the quick reply

    – sam
    Jul 2 '13 at 19:29











  • If i use rename it says not a valid command

    – sam
    Jul 2 '13 at 19:32











  • How are you running the command? Is it part of a script?

    – user26112
    Jul 2 '13 at 20:07






  • 1





    I've never used ksh or winscp so I may be missing something, but I find it strange that you're receiving an error on line 6 when you're only running one line.

    – user26112
    Jul 2 '13 at 20:36





















-1














I am not clear how come below command working for only one file 32456113-report.pdf



for f in * ; do mv "$f" "$(eval echo ${$f})" ; done



I tried for below file, but it didn't work.



201901070824393776_90_I477_AM_ABS.zip.pgp



error:
-bash: ${201901070824393776_90_I477-AM_ABS.zip.pgp}: bad substitution
mv: cannot move 201901070824393776_90_I477-AM_ABS.zip.pgp' to': No such file or directory



I am not clear with $(eval echo ${$f}) , How can I remove numeric value from my file? I need to remove "201901070824393776_90_I477-"



Can someone help with this?





share








New contributor




sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    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%2f81521%2fneed-to-trim-the-names-of-file-names%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    for f in *; do 
    regular="${f#*-}"
    echo "$f => $regular"
    done


    This parameter expansion (${f#*-}) removes, from the start of the variable's value, the shortest string that ends with a hyphen (see manual). So:



    $ f=32456113-summary-report.doc
    $ echo "$f => ${f#*-}"
    32456113-summary-report.doc => summary-report.doc





    share|improve this answer
























    • mv: cannot rename /tmp/34178248 to /tmp/34178248//34178248: Invalid argument /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3: bad substitution /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3 Program exited with status 1

      – sam
      Jul 2 '13 at 20:41











    • This code might not work for ksh, which is what @sam is using.

      – user26112
      Jul 2 '13 at 20:42













    • This code does work in ksh, that's where I tested it. @sam, please show what you're actually running, edit your question with more details please.

      – glenn jackman
      Jul 2 '13 at 20:45













    • mv -- "34178248-2640006.pdf" "${34178248-2640006.pdf}" when i use this i got the desired result, can i automate the process for all the files in the directory

      – sam
      Jul 2 '13 at 23:39
















    3














    for f in *; do 
    regular="${f#*-}"
    echo "$f => $regular"
    done


    This parameter expansion (${f#*-}) removes, from the start of the variable's value, the shortest string that ends with a hyphen (see manual). So:



    $ f=32456113-summary-report.doc
    $ echo "$f => ${f#*-}"
    32456113-summary-report.doc => summary-report.doc





    share|improve this answer
























    • mv: cannot rename /tmp/34178248 to /tmp/34178248//34178248: Invalid argument /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3: bad substitution /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3 Program exited with status 1

      – sam
      Jul 2 '13 at 20:41











    • This code might not work for ksh, which is what @sam is using.

      – user26112
      Jul 2 '13 at 20:42













    • This code does work in ksh, that's where I tested it. @sam, please show what you're actually running, edit your question with more details please.

      – glenn jackman
      Jul 2 '13 at 20:45













    • mv -- "34178248-2640006.pdf" "${34178248-2640006.pdf}" when i use this i got the desired result, can i automate the process for all the files in the directory

      – sam
      Jul 2 '13 at 23:39














    3












    3








    3







    for f in *; do 
    regular="${f#*-}"
    echo "$f => $regular"
    done


    This parameter expansion (${f#*-}) removes, from the start of the variable's value, the shortest string that ends with a hyphen (see manual). So:



    $ f=32456113-summary-report.doc
    $ echo "$f => ${f#*-}"
    32456113-summary-report.doc => summary-report.doc





    share|improve this answer













    for f in *; do 
    regular="${f#*-}"
    echo "$f => $regular"
    done


    This parameter expansion (${f#*-}) removes, from the start of the variable's value, the shortest string that ends with a hyphen (see manual). So:



    $ f=32456113-summary-report.doc
    $ echo "$f => ${f#*-}"
    32456113-summary-report.doc => summary-report.doc






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 2 '13 at 20:34









    glenn jackmanglenn jackman

    50.6k570108




    50.6k570108













    • mv: cannot rename /tmp/34178248 to /tmp/34178248//34178248: Invalid argument /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3: bad substitution /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3 Program exited with status 1

      – sam
      Jul 2 '13 at 20:41











    • This code might not work for ksh, which is what @sam is using.

      – user26112
      Jul 2 '13 at 20:42













    • This code does work in ksh, that's where I tested it. @sam, please show what you're actually running, edit your question with more details please.

      – glenn jackman
      Jul 2 '13 at 20:45













    • mv -- "34178248-2640006.pdf" "${34178248-2640006.pdf}" when i use this i got the desired result, can i automate the process for all the files in the directory

      – sam
      Jul 2 '13 at 23:39



















    • mv: cannot rename /tmp/34178248 to /tmp/34178248//34178248: Invalid argument /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3: bad substitution /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3 Program exited with status 1

      – sam
      Jul 2 '13 at 20:41











    • This code might not work for ksh, which is what @sam is using.

      – user26112
      Jul 2 '13 at 20:42













    • This code does work in ksh, that's where I tested it. @sam, please show what you're actually running, edit your question with more details please.

      – glenn jackman
      Jul 2 '13 at 20:45













    • mv -- "34178248-2640006.pdf" "${34178248-2640006.pdf}" when i use this i got the desired result, can i automate the process for all the files in the directory

      – sam
      Jul 2 '13 at 23:39

















    mv: cannot rename /tmp/34178248 to /tmp/34178248//34178248: Invalid argument /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3: bad substitution /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3 Program exited with status 1

    – sam
    Jul 2 '13 at 20:41





    mv: cannot rename /tmp/34178248 to /tmp/34178248//34178248: Invalid argument /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3: bad substitution /u01/R2ID10/R2ID10appl/xxps/11.5.0/bin/XXPS_MULTIPLE_EMAIL3 Program exited with status 1

    – sam
    Jul 2 '13 at 20:41













    This code might not work for ksh, which is what @sam is using.

    – user26112
    Jul 2 '13 at 20:42







    This code might not work for ksh, which is what @sam is using.

    – user26112
    Jul 2 '13 at 20:42















    This code does work in ksh, that's where I tested it. @sam, please show what you're actually running, edit your question with more details please.

    – glenn jackman
    Jul 2 '13 at 20:45







    This code does work in ksh, that's where I tested it. @sam, please show what you're actually running, edit your question with more details please.

    – glenn jackman
    Jul 2 '13 at 20:45















    mv -- "34178248-2640006.pdf" "${34178248-2640006.pdf}" when i use this i got the desired result, can i automate the process for all the files in the directory

    – sam
    Jul 2 '13 at 23:39





    mv -- "34178248-2640006.pdf" "${34178248-2640006.pdf}" when i use this i got the desired result, can i automate the process for all the files in the directory

    – sam
    Jul 2 '13 at 23:39













    1














    Not entirely sure I understand what you are trying to do, but I believe a simple bash script as follows would work



    for f in * ; do mv "$f" "$(echo "$f" | cut -d- -f2)"; done


    If you don't like the echo to cut nonsense, I can look up the string rules in bash for you.






    share|improve this answer


























    • I fixed up your code a bit to include more quotation marks. Also, don't parse ls output.

      – user26112
      Jul 2 '13 at 20:09











    • :) Thanks! I should have known better than parsing ls, but was too blinded by not immediately knowing the string rules of bash.

      – Josh Berry
      Jul 2 '13 at 20:15











    • Apparently the original poster is using ksh.

      – user26112
      Jul 2 '13 at 20:17











    • Thanks for your reply..... my file name is changed but it was like this $(echo 34178248-BPI_TAX_EX--.pdf | cut -d- -f2). Any suggestion, i really appreciate for your time

      – sam
      Jul 2 '13 at 20:31











    • You can use cut -d- -f2- instead.

      – user26112
      Jul 2 '13 at 20:35
















    1














    Not entirely sure I understand what you are trying to do, but I believe a simple bash script as follows would work



    for f in * ; do mv "$f" "$(echo "$f" | cut -d- -f2)"; done


    If you don't like the echo to cut nonsense, I can look up the string rules in bash for you.






    share|improve this answer


























    • I fixed up your code a bit to include more quotation marks. Also, don't parse ls output.

      – user26112
      Jul 2 '13 at 20:09











    • :) Thanks! I should have known better than parsing ls, but was too blinded by not immediately knowing the string rules of bash.

      – Josh Berry
      Jul 2 '13 at 20:15











    • Apparently the original poster is using ksh.

      – user26112
      Jul 2 '13 at 20:17











    • Thanks for your reply..... my file name is changed but it was like this $(echo 34178248-BPI_TAX_EX--.pdf | cut -d- -f2). Any suggestion, i really appreciate for your time

      – sam
      Jul 2 '13 at 20:31











    • You can use cut -d- -f2- instead.

      – user26112
      Jul 2 '13 at 20:35














    1












    1








    1







    Not entirely sure I understand what you are trying to do, but I believe a simple bash script as follows would work



    for f in * ; do mv "$f" "$(echo "$f" | cut -d- -f2)"; done


    If you don't like the echo to cut nonsense, I can look up the string rules in bash for you.






    share|improve this answer















    Not entirely sure I understand what you are trying to do, but I believe a simple bash script as follows would work



    for f in * ; do mv "$f" "$(echo "$f" | cut -d- -f2)"; done


    If you don't like the echo to cut nonsense, I can look up the string rules in bash for you.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jul 2 '13 at 20:08







    user26112

















    answered Jul 2 '13 at 20:05









    Josh BerryJosh Berry

    69144




    69144













    • I fixed up your code a bit to include more quotation marks. Also, don't parse ls output.

      – user26112
      Jul 2 '13 at 20:09











    • :) Thanks! I should have known better than parsing ls, but was too blinded by not immediately knowing the string rules of bash.

      – Josh Berry
      Jul 2 '13 at 20:15











    • Apparently the original poster is using ksh.

      – user26112
      Jul 2 '13 at 20:17











    • Thanks for your reply..... my file name is changed but it was like this $(echo 34178248-BPI_TAX_EX--.pdf | cut -d- -f2). Any suggestion, i really appreciate for your time

      – sam
      Jul 2 '13 at 20:31











    • You can use cut -d- -f2- instead.

      – user26112
      Jul 2 '13 at 20:35



















    • I fixed up your code a bit to include more quotation marks. Also, don't parse ls output.

      – user26112
      Jul 2 '13 at 20:09











    • :) Thanks! I should have known better than parsing ls, but was too blinded by not immediately knowing the string rules of bash.

      – Josh Berry
      Jul 2 '13 at 20:15











    • Apparently the original poster is using ksh.

      – user26112
      Jul 2 '13 at 20:17











    • Thanks for your reply..... my file name is changed but it was like this $(echo 34178248-BPI_TAX_EX--.pdf | cut -d- -f2). Any suggestion, i really appreciate for your time

      – sam
      Jul 2 '13 at 20:31











    • You can use cut -d- -f2- instead.

      – user26112
      Jul 2 '13 at 20:35

















    I fixed up your code a bit to include more quotation marks. Also, don't parse ls output.

    – user26112
    Jul 2 '13 at 20:09





    I fixed up your code a bit to include more quotation marks. Also, don't parse ls output.

    – user26112
    Jul 2 '13 at 20:09













    :) Thanks! I should have known better than parsing ls, but was too blinded by not immediately knowing the string rules of bash.

    – Josh Berry
    Jul 2 '13 at 20:15





    :) Thanks! I should have known better than parsing ls, but was too blinded by not immediately knowing the string rules of bash.

    – Josh Berry
    Jul 2 '13 at 20:15













    Apparently the original poster is using ksh.

    – user26112
    Jul 2 '13 at 20:17





    Apparently the original poster is using ksh.

    – user26112
    Jul 2 '13 at 20:17













    Thanks for your reply..... my file name is changed but it was like this $(echo 34178248-BPI_TAX_EX--.pdf | cut -d- -f2). Any suggestion, i really appreciate for your time

    – sam
    Jul 2 '13 at 20:31





    Thanks for your reply..... my file name is changed but it was like this $(echo 34178248-BPI_TAX_EX--.pdf | cut -d- -f2). Any suggestion, i really appreciate for your time

    – sam
    Jul 2 '13 at 20:31













    You can use cut -d- -f2- instead.

    – user26112
    Jul 2 '13 at 20:35





    You can use cut -d- -f2- instead.

    – user26112
    Jul 2 '13 at 20:35











    1














    You can use perl-rename.



    perl-rename 's/[0-9]*-//' <files>


    Depending your OS/distro, this utility may be called rename. To be safe, use the -n flag with perl-rename to do a dry run before actually renaming any files.






    share|improve this answer


























    • ksh[6]: syntax error at line 6 : ';' unexpected.... i got this when i run the above command in winscp

      – sam
      Jul 2 '13 at 19:29











    • and Thanks for the quick reply

      – sam
      Jul 2 '13 at 19:29











    • If i use rename it says not a valid command

      – sam
      Jul 2 '13 at 19:32











    • How are you running the command? Is it part of a script?

      – user26112
      Jul 2 '13 at 20:07






    • 1





      I've never used ksh or winscp so I may be missing something, but I find it strange that you're receiving an error on line 6 when you're only running one line.

      – user26112
      Jul 2 '13 at 20:36


















    1














    You can use perl-rename.



    perl-rename 's/[0-9]*-//' <files>


    Depending your OS/distro, this utility may be called rename. To be safe, use the -n flag with perl-rename to do a dry run before actually renaming any files.






    share|improve this answer


























    • ksh[6]: syntax error at line 6 : ';' unexpected.... i got this when i run the above command in winscp

      – sam
      Jul 2 '13 at 19:29











    • and Thanks for the quick reply

      – sam
      Jul 2 '13 at 19:29











    • If i use rename it says not a valid command

      – sam
      Jul 2 '13 at 19:32











    • How are you running the command? Is it part of a script?

      – user26112
      Jul 2 '13 at 20:07






    • 1





      I've never used ksh or winscp so I may be missing something, but I find it strange that you're receiving an error on line 6 when you're only running one line.

      – user26112
      Jul 2 '13 at 20:36
















    1












    1








    1







    You can use perl-rename.



    perl-rename 's/[0-9]*-//' <files>


    Depending your OS/distro, this utility may be called rename. To be safe, use the -n flag with perl-rename to do a dry run before actually renaming any files.






    share|improve this answer















    You can use perl-rename.



    perl-rename 's/[0-9]*-//' <files>


    Depending your OS/distro, this utility may be called rename. To be safe, use the -n flag with perl-rename to do a dry run before actually renaming any files.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jul 2 '13 at 20:37

























    answered Jul 2 '13 at 19:22







    user26112




















    • ksh[6]: syntax error at line 6 : ';' unexpected.... i got this when i run the above command in winscp

      – sam
      Jul 2 '13 at 19:29











    • and Thanks for the quick reply

      – sam
      Jul 2 '13 at 19:29











    • If i use rename it says not a valid command

      – sam
      Jul 2 '13 at 19:32











    • How are you running the command? Is it part of a script?

      – user26112
      Jul 2 '13 at 20:07






    • 1





      I've never used ksh or winscp so I may be missing something, but I find it strange that you're receiving an error on line 6 when you're only running one line.

      – user26112
      Jul 2 '13 at 20:36





















    • ksh[6]: syntax error at line 6 : ';' unexpected.... i got this when i run the above command in winscp

      – sam
      Jul 2 '13 at 19:29











    • and Thanks for the quick reply

      – sam
      Jul 2 '13 at 19:29











    • If i use rename it says not a valid command

      – sam
      Jul 2 '13 at 19:32











    • How are you running the command? Is it part of a script?

      – user26112
      Jul 2 '13 at 20:07






    • 1





      I've never used ksh or winscp so I may be missing something, but I find it strange that you're receiving an error on line 6 when you're only running one line.

      – user26112
      Jul 2 '13 at 20:36



















    ksh[6]: syntax error at line 6 : ';' unexpected.... i got this when i run the above command in winscp

    – sam
    Jul 2 '13 at 19:29





    ksh[6]: syntax error at line 6 : ';' unexpected.... i got this when i run the above command in winscp

    – sam
    Jul 2 '13 at 19:29













    and Thanks for the quick reply

    – sam
    Jul 2 '13 at 19:29





    and Thanks for the quick reply

    – sam
    Jul 2 '13 at 19:29













    If i use rename it says not a valid command

    – sam
    Jul 2 '13 at 19:32





    If i use rename it says not a valid command

    – sam
    Jul 2 '13 at 19:32













    How are you running the command? Is it part of a script?

    – user26112
    Jul 2 '13 at 20:07





    How are you running the command? Is it part of a script?

    – user26112
    Jul 2 '13 at 20:07




    1




    1





    I've never used ksh or winscp so I may be missing something, but I find it strange that you're receiving an error on line 6 when you're only running one line.

    – user26112
    Jul 2 '13 at 20:36







    I've never used ksh or winscp so I may be missing something, but I find it strange that you're receiving an error on line 6 when you're only running one line.

    – user26112
    Jul 2 '13 at 20:36













    -1














    I am not clear how come below command working for only one file 32456113-report.pdf



    for f in * ; do mv "$f" "$(eval echo ${$f})" ; done



    I tried for below file, but it didn't work.



    201901070824393776_90_I477_AM_ABS.zip.pgp



    error:
    -bash: ${201901070824393776_90_I477-AM_ABS.zip.pgp}: bad substitution
    mv: cannot move 201901070824393776_90_I477-AM_ABS.zip.pgp' to': No such file or directory



    I am not clear with $(eval echo ${$f}) , How can I remove numeric value from my file? I need to remove "201901070824393776_90_I477-"



    Can someone help with this?





    share








    New contributor




    sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      -1














      I am not clear how come below command working for only one file 32456113-report.pdf



      for f in * ; do mv "$f" "$(eval echo ${$f})" ; done



      I tried for below file, but it didn't work.



      201901070824393776_90_I477_AM_ABS.zip.pgp



      error:
      -bash: ${201901070824393776_90_I477-AM_ABS.zip.pgp}: bad substitution
      mv: cannot move 201901070824393776_90_I477-AM_ABS.zip.pgp' to': No such file or directory



      I am not clear with $(eval echo ${$f}) , How can I remove numeric value from my file? I need to remove "201901070824393776_90_I477-"



      Can someone help with this?





      share








      New contributor




      sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        -1












        -1








        -1







        I am not clear how come below command working for only one file 32456113-report.pdf



        for f in * ; do mv "$f" "$(eval echo ${$f})" ; done



        I tried for below file, but it didn't work.



        201901070824393776_90_I477_AM_ABS.zip.pgp



        error:
        -bash: ${201901070824393776_90_I477-AM_ABS.zip.pgp}: bad substitution
        mv: cannot move 201901070824393776_90_I477-AM_ABS.zip.pgp' to': No such file or directory



        I am not clear with $(eval echo ${$f}) , How can I remove numeric value from my file? I need to remove "201901070824393776_90_I477-"



        Can someone help with this?





        share








        New contributor




        sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        I am not clear how come below command working for only one file 32456113-report.pdf



        for f in * ; do mv "$f" "$(eval echo ${$f})" ; done



        I tried for below file, but it didn't work.



        201901070824393776_90_I477_AM_ABS.zip.pgp



        error:
        -bash: ${201901070824393776_90_I477-AM_ABS.zip.pgp}: bad substitution
        mv: cannot move 201901070824393776_90_I477-AM_ABS.zip.pgp' to': No such file or directory



        I am not clear with $(eval echo ${$f}) , How can I remove numeric value from my file? I need to remove "201901070824393776_90_I477-"



        Can someone help with this?






        share








        New contributor




        sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share


        share






        New contributor




        sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 9 mins ago









        sridhar kasanagottusridhar kasanagottu

        1




        1




        New contributor




        sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        sridhar kasanagottu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            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%2f81521%2fneed-to-trim-the-names-of-file-names%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

            Entries order in /etc/network/interfaces

            Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)

            新発田市