Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Using echo for multiple files

  • 29-03-2002 10: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,564 ✭✭✭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,564 ✭✭✭Typedef


    Yeah that might work too.
    :rolleyes: .

    Handbags at dawn?


  • Advertisement
Advertisement