In part 2 what do you mean "compares"? That suggests that some operation should be performed if some condition is true, but you do not say what.
In general, you can use a while read loop to take input from the keyboard: Code:
echo -n "Enter a file name> " |
sorry for my late explanation (LOL)
Hi mathew,
What I want to says with "compares" in a short example it's something like this. Input from user tabela2.txt v:=read (file) the file will be stored in v so now we could make the "compare" z is a list where inside has something like this: tabela1.txt 158 (characaters) tabela2.txt 38 (characters) tabela3.txt 45 (characters) if v exist in z then (it goes to the 8th cycle) and do something like this. :8 while read line; do if [ ${#line} -lt 38 ]; then echo "${line}0" else echo "${line}" fi done but if the file it's tabela3.txt then he goes to :7 while read line; do if [ ${#line} -lt 45]; then echo "${line}0" else echo "${line}" fi done Thanks |
Speed up to analyse
Hi there !!
Is any way to accelarate scripts on Linux I've got files with 1 million (near of 2 million) of lines and to analyse 12 files it takes 2 days if I have 70 files it will be longer with the time. Is there anyway to accelarate this situation ? Thanks best Rgeards |
Shell scripts are really a quick and quite slow glue for combining the functionality of other programs. As I told you in post #5 of this thread, they are not good for line-by-line editing of large sets of data. You should consider writing your program in a language more suited to the task, such as Perl or Python.
|
awk
Hi
Thanks Mathew (again) But could awk be more quicker than my script ? Thanks |
For sure awk will be a lot faster than a shell script in this case. Perl will probably be even faster, although it's more to learn than awk, so maybe awk would be easier to get started with.
For example, I created a large test file (15 meg / 100000 lines) and ran the shell script on it. The time used by the process was over 31 seconds. When I did the same thing with an awk program it took just 1.7 seconds. A similar program written in Perl took less than half a second. The text processing part of the program in awk looks like this: Code:
{ |
If you decide to go with Perl, start here: http://perldoc.perl.org/
|
All times are GMT -5. The time now is 02:56 AM. |