Results 1 to 7 of 7

Thread: how to create multiple file in a single command

  1. #1
    Junior Member
    Join Date
    Jul 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default how to create multiple file in a single command

    hi,

    i want to create in the extension of ".txt"

    IS there any command available
    for careating the ten file in the name of

    a1.txt , a2.txt, a3.txt .... a10.txt

    if u know the command help to me

    thanks

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,512
    Thanks
    17
    Thanked 799 Times in 511 Posts
    Rep Power
    10

    Default

    Use touch or other command as follows
    Code:
    touch a{1,2,3,4,5,6,7,8,9,10}.txt
    there are other ways too but this is easy for 10 files
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  3. #3
    Junior Member
    Join Date
    Jul 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default thanks with a query

    hi

    ur command is working

    thanks

    could u tell me more about xargs,awk in shell script

  4. #4
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,512
    Thanks
    17
    Thanked 799 Times in 511 Posts
    Rep Power
    10

    Default

    could u tell me more about xargs,awk in shell script
    awk is small programming language pattern scanning and processing with C like syntax. It is quite useful for processing text-based data. Please note that limitations of AWK programs (and sed scripts) lead into development of perl.

    xargs build and execute command lines from standard input or shell pipes. For example find all *.tmp file and remove them:

    Code:
    find . -name "*.tmp" | xargs rm
    if you have specific question(s), please start a new topic.
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  5. #5
    Junior Member
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Easier command would be touch a{1..10}.txt

  6. #6
    Junior Member
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by andyflag View Post
    Easier command would be touch a{1..10}.txt
    could you please tell me how can create multiple contents of a file.

    let say an example : file name is a.txt. in this file i want to write multiple contents. In this way i want create 10 files with multiple contents and every files are different contents.

  7. #7
    Senior Member Rahul.Patil's Avatar
    Join Date
    Feb 2012
    Location
    Mumbai india
    Posts
    485
    Thanks
    10
    Thanked 49 Times in 46 Posts
    Rep Power
    8

    Default

    Hi,
    you can use this small script
    HTML Code:
    #!/bin/bash
    
    random_content () {
    < /dev/urandom tr -dc A-Za-z0-9_ | head -c300
    }
    
    for I in {1..10}
    do
    touch file$I.txt
    random_content > file$I.txt
    done

  8. The Following User Says Thank You to Rahul.Patil For This Useful Post:

    lovely (24th April 2012)

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. [Solved] How to create multiple user account?
    By droidwork in forum Shell scripting
    Replies: 14
    Last Post: 20th October 2010, 10:30 AM
  2. Create new user account in Ubuntu Linux from command line
    By sweta in forum Getting started tutorials
    Replies: 3
    Last Post: 7th February 2010, 12:15 PM
  3. single DHCP server with multiple VLAN's
    By frank in forum Computer Networking and Internet/broadband
    Replies: 2
    Last Post: 7th December 2007, 12:38 PM
  4. Replies: 2
    Last Post: 17th March 2007, 04:48 AM
  5. Replies: 0
    Last Post: 20th December 2006, 02:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •