Escape a backup date in a file namethe slash (/) after a directory name on shell commandsDate time in Linux bashCreate sub-directories and organize files by date from file nameWhat is the difference between a directory name that ends with a slash and one that does not?How do you put date and time in a file name?adding date to beginning of file name using scripttcsh - echo escape code for escapeConvert date in bash shellHow to adjust the Exif timestamp of a photo using the date in its nameshell script to walk folders and sub-folders, convert timestamp to UTC format and export .csv file

Sequence of Tenses: Translating the subjunctive

How does the UK government determine the size of a mandate?

What does "I’d sit this one out, Cap," imply or mean in the context?

Why not increase contact surface when reentering the atmosphere?

What is the difference between "behavior" and "behaviour"?

Is there a problem with hiding "forgot password" until it's needed?

How to run a prison with the smallest amount of guards?

Two monoidal structures and copowering

Unreliable Magic - Is it worth it?

Trouble understanding the speech of overseas colleagues

Sort a list by elements of another list

Type int? vs type int

How easy is it to start Magic from scratch?

What can we do to stop prior company from asking us questions?

Anatomically Correct Strange Women In Ponds Distributing Swords

Why are there no referendums in the US?

Is there a good way to store credentials outside of a password manager?

Applicability of Single Responsibility Principle

How can we prove that any integral in the set of non-elementary integrals cannot be expressed in the form of elementary functions?

Short story about space worker geeks who zone out by 'listening' to radiation from stars

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

Is expanding the research of a group into machine learning as a PhD student risky?

How can a function with a hole (removable discontinuity) equal a function with no hole?

How to be diplomatic in refusing to write code that breaches the privacy of our users



Escape a backup date in a file name


the slash (/) after a directory name on shell commandsDate time in Linux bashCreate sub-directories and organize files by date from file nameWhat is the difference between a directory name that ends with a slash and one that does not?How do you put date and time in a file name?adding date to beginning of file name using scripttcsh - echo escape code for escapeConvert date in bash shellHow to adjust the Exif timestamp of a photo using the date in its nameshell script to walk folders and sub-folders, convert timestamp to UTC format and export .csv file













3















I have been trying to:



cp file.csv file.$(date +%D).csv


But it fails because the filenames is: file.03/27/19.csv with the slash of separate directories.



And I have been trying again to:



cp file.csv file.$(printf "%q" $(date +%D)).csv


But it still fails.










share|improve this question
























  • You can not set a filename with slash characters: stackoverflow.com/questions/9847288/…

    – tres.14159
    7 hours ago











  • the problem is your use of the date format using the / character. You said it yourself, the shell is seeing them as directory markers. Try one of the many other options available from date. You might be able to get the / escaped so the filename uses the character code (like putting a space in a filename), but that is often problematic.

    – 0xSheepdog
    7 hours ago
















3















I have been trying to:



cp file.csv file.$(date +%D).csv


But it fails because the filenames is: file.03/27/19.csv with the slash of separate directories.



And I have been trying again to:



cp file.csv file.$(printf "%q" $(date +%D)).csv


But it still fails.










share|improve this question
























  • You can not set a filename with slash characters: stackoverflow.com/questions/9847288/…

    – tres.14159
    7 hours ago











  • the problem is your use of the date format using the / character. You said it yourself, the shell is seeing them as directory markers. Try one of the many other options available from date. You might be able to get the / escaped so the filename uses the character code (like putting a space in a filename), but that is often problematic.

    – 0xSheepdog
    7 hours ago














3












3








3








I have been trying to:



cp file.csv file.$(date +%D).csv


But it fails because the filenames is: file.03/27/19.csv with the slash of separate directories.



And I have been trying again to:



cp file.csv file.$(printf "%q" $(date +%D)).csv


But it still fails.










share|improve this question
















I have been trying to:



cp file.csv file.$(date +%D).csv


But it fails because the filenames is: file.03/27/19.csv with the slash of separate directories.



And I have been trying again to:



cp file.csv file.$(printf "%q" $(date +%D)).csv


But it still fails.







shell filenames date escape-characters slash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago









Gilles

544k12811041621




544k12811041621










asked 7 hours ago









tres.14159tres.14159

2612




2612












  • You can not set a filename with slash characters: stackoverflow.com/questions/9847288/…

    – tres.14159
    7 hours ago











  • the problem is your use of the date format using the / character. You said it yourself, the shell is seeing them as directory markers. Try one of the many other options available from date. You might be able to get the / escaped so the filename uses the character code (like putting a space in a filename), but that is often problematic.

    – 0xSheepdog
    7 hours ago


















  • You can not set a filename with slash characters: stackoverflow.com/questions/9847288/…

    – tres.14159
    7 hours ago











  • the problem is your use of the date format using the / character. You said it yourself, the shell is seeing them as directory markers. Try one of the many other options available from date. You might be able to get the / escaped so the filename uses the character code (like putting a space in a filename), but that is often problematic.

    – 0xSheepdog
    7 hours ago

















You can not set a filename with slash characters: stackoverflow.com/questions/9847288/…

– tres.14159
7 hours ago





You can not set a filename with slash characters: stackoverflow.com/questions/9847288/…

– tres.14159
7 hours ago













the problem is your use of the date format using the / character. You said it yourself, the shell is seeing them as directory markers. Try one of the many other options available from date. You might be able to get the / escaped so the filename uses the character code (like putting a space in a filename), but that is often problematic.

– 0xSheepdog
7 hours ago






the problem is your use of the date format using the / character. You said it yourself, the shell is seeing them as directory markers. Try one of the many other options available from date. You might be able to get the / escaped so the filename uses the character code (like putting a space in a filename), but that is often problematic.

– 0xSheepdog
7 hours ago











1 Answer
1






active

oldest

votes


















11














You can't have / (byte 0x2F on ASCII-based systems) in a file name, period.



You can use characters that look like / like (fraction slash), so you could do:



 cp file.csv "file.$(date +%D | sed 's|/|⁄|g').csv"


But you may run into problems like the file name being rendered differently in locales using a different charset.



My advice would be to use the standard non-ambiguous (for most people outside the US, 03/12/18 would be interpreted as the 3rd of December 2018 for instance) YYYY-mm-dd format instead (which also helps wrt sorting):



 cp file.csv "file.$(date +%Y-%m-%d).csv"


Which with many date implementations you can shorten to:



 cp file.csv "file.$(date +%F).csv"





share|improve this answer
























    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%2f509043%2fescape-a-backup-date-in-a-file-name%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









    11














    You can't have / (byte 0x2F on ASCII-based systems) in a file name, period.



    You can use characters that look like / like (fraction slash), so you could do:



     cp file.csv "file.$(date +%D | sed 's|/|⁄|g').csv"


    But you may run into problems like the file name being rendered differently in locales using a different charset.



    My advice would be to use the standard non-ambiguous (for most people outside the US, 03/12/18 would be interpreted as the 3rd of December 2018 for instance) YYYY-mm-dd format instead (which also helps wrt sorting):



     cp file.csv "file.$(date +%Y-%m-%d).csv"


    Which with many date implementations you can shorten to:



     cp file.csv "file.$(date +%F).csv"





    share|improve this answer





























      11














      You can't have / (byte 0x2F on ASCII-based systems) in a file name, period.



      You can use characters that look like / like (fraction slash), so you could do:



       cp file.csv "file.$(date +%D | sed 's|/|⁄|g').csv"


      But you may run into problems like the file name being rendered differently in locales using a different charset.



      My advice would be to use the standard non-ambiguous (for most people outside the US, 03/12/18 would be interpreted as the 3rd of December 2018 for instance) YYYY-mm-dd format instead (which also helps wrt sorting):



       cp file.csv "file.$(date +%Y-%m-%d).csv"


      Which with many date implementations you can shorten to:



       cp file.csv "file.$(date +%F).csv"





      share|improve this answer



























        11












        11








        11







        You can't have / (byte 0x2F on ASCII-based systems) in a file name, period.



        You can use characters that look like / like (fraction slash), so you could do:



         cp file.csv "file.$(date +%D | sed 's|/|⁄|g').csv"


        But you may run into problems like the file name being rendered differently in locales using a different charset.



        My advice would be to use the standard non-ambiguous (for most people outside the US, 03/12/18 would be interpreted as the 3rd of December 2018 for instance) YYYY-mm-dd format instead (which also helps wrt sorting):



         cp file.csv "file.$(date +%Y-%m-%d).csv"


        Which with many date implementations you can shorten to:



         cp file.csv "file.$(date +%F).csv"





        share|improve this answer















        You can't have / (byte 0x2F on ASCII-based systems) in a file name, period.



        You can use characters that look like / like (fraction slash), so you could do:



         cp file.csv "file.$(date +%D | sed 's|/|⁄|g').csv"


        But you may run into problems like the file name being rendered differently in locales using a different charset.



        My advice would be to use the standard non-ambiguous (for most people outside the US, 03/12/18 would be interpreted as the 3rd of December 2018 for instance) YYYY-mm-dd format instead (which also helps wrt sorting):



         cp file.csv "file.$(date +%Y-%m-%d).csv"


        Which with many date implementations you can shorten to:



         cp file.csv "file.$(date +%F).csv"






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 6 hours ago

























        answered 7 hours ago









        Stéphane ChazelasStéphane Chazelas

        311k57588946




        311k57588946



























            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%2f509043%2fescape-a-backup-date-in-a-file-name%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 create a command for the “strange m” symbol in latex? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do you make your own symbol when Detexify fails?Writing bold small caps with mathpazo packageplus-minus symbol with parenthesis around the minus signGreek character in Beamer document titleHow to create dashed right arrow over symbol?Currency symbol: Turkish LiraDouble prec as a single symbol?Plus Sign Too Big; How to Call adfbullet?Is there a TeX macro for three-legged pi?How do I get my integral-like symbol to align like the integral?How to selectively substitute a letter with another symbol representing the same letterHow do I generate a less than symbol and vertical bar that are the same height?

            Българска екзархия Съдържание История | Български екзарси | Вижте също | Външни препратки | Литература | Бележки | НавигацияУстав за управлението на българската екзархия. Цариград, 1870Слово на Ловешкия митрополит Иларион при откриването на Българския народен събор в Цариград на 23. II. 1870 г.Българската правда и гръцката кривда. От С. М. (= Софийски Мелетий). Цариград, 1872Предстоятели на Българската екзархияПодмененият ВеликденИнформационна агенция „Фокус“Димитър Ризов. Българите в техните исторически, етнографически и политически граници (Атлас съдържащ 40 карти). Berlin, Königliche Hoflithographie, Hof-Buch- und -Steindruckerei Wilhelm Greve, 1917Report of the International Commission to Inquire into the Causes and Conduct of the Balkan Wars

            Чепеларе Съдържание География | История | Население | Спортни и природни забележителности | Културни и исторически обекти | Религии | Обществени институции | Известни личности | Редовни събития | Галерия | Източници | Литература | Външни препратки | Навигация41°43′23.99″ с. ш. 24°41′09.99″ и. д. / 41.723333° с. ш. 24.686111° и. д.*ЧепелареЧепеларски Linux fest 2002Начало на Зимен сезон 2005/06Национални хайдушки празници „Капитан Петко Войвода“Град ЧепелареЧепеларе – народният ски курортbgrod.orgwww.terranatura.hit.bgСправка за населението на гр. Исперих, общ. Исперих, обл. РазградМузей на родопския карстМузей на спорта и скитеЧепеларебългарскибългарскианглийскитукИстория на градаСки писти в ЧепелареВремето в ЧепелареРадио и телевизия в ЧепелареЧепеларе мами с родопски чар и добри пистиЕвтин туризъм и снежни атракции в ЧепелареМестоположениеИнформация и снимки от музея на родопския карст3D панорами от ЧепелареЧепелареррр