Bash script questions.
Hi guys:
Do you know how to create a file in script? And how to "connect" the file name? For example, I want to create N files, each file name is Rand_i.out, (i from 1 to N) Then How can I connect "Rank_" and "i" in a loop? Appreciate! |
you need to give us more to go on than that. you "create" files just as normal...
maybe this is what you're after... Code:
for i in $(seq 1 10) |
Take a look at linuxcommand.org website, it's got what you're asking for (I think) and lots of more. If I understand you right, you need a loop (like FOR for example, or whatever you prefer) and then use (again -- for example) touch to create the files and depending on what you want to do with them, use > or >> to write data into the files (for example; > overwrites existing data and >> appends to the file; it's explained in the website I mentioned).
|
Thanks a lot,
Here is my code: NPROCS=10 index while [$index -lt $NPROCS]; do echo file $(index) > Rank_$(index).out done It can't pass compilation, what's wrong with it?? Quote:
|
you could start by telling us the errors... kinda helps..
but for starters 1) your [ syntax is wrong, put spaces either side of [ and ]. and 2) you're not incrementing your value, the test will always be true. |
Moreover, you are not setting an initial value to the index variable.
|
Quote:
|
All times are GMT -5. The time now is 10:02 AM. |