Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Using echo for multiple files

  • 29-03-2002 11:07AM
    #1
    Closed Accounts Posts: 74 ✭✭


    Hi,
    I want to place text into multiple files using echo.I don't care whats in the files at the moment so I am redirecting the stdout via >
    Basically I want to do the following but it's not working... anysuggestions.

    echo "Some text and html here<p>" > file1.txt file2.txt.


Comments

  • Closed Accounts Posts: 3,859 ✭✭✭logic1


    Well you could use something like:
    echo "Some text and html here" > file1.txt | cat file1.txt >> file2.txt
    

    .logic.


  • Closed Accounts Posts: 74 ✭✭root


    Thanks for the reply.
    However it would get a bit repetitive considering that I have about 10 files.


  • Closed Accounts Posts: 5,563 ✭✭✭Typedef


    Originally posted by logic1
    Well you could use something like:

    echo "Some text and html here" > file1.txt | cat file1.txt >> file2.txt
    

    .logic.

    or how about
    #n.sh
    
    read var1
    x=0
    
    while ["$x" -ne "$var1"]
            cat base.txt > "$x".txt
            x=$(($x+1))
    done
    exit 0
    

    then type
    echo "hello world" > base.txt | ./n.sh 10


  • Closed Accounts Posts: 286 ✭✭Kev


    what about

    echo "text" | tee file1 file2 file3 > /dev/null


  • Closed Accounts Posts: 5,563 ✭✭✭Typedef


    Yeah that might work too.
    :rolleyes: .

    Handbags at dawn?


  • Advertisement
Advertisement