this is a part of my code :
the echo return nothing (as my variable is empty).
I'm sure that the problem becomes from my syntaxe, because, if in the expression I replace "$ligne" by a string corresponding with my extension files, it works. The second point is that is not because ligne would be empty, because I test with an echo the return of my variable result and It isn't empty.
Please Help me... I turn a round with this problem since this morning.
thanks for your help.
regards.
Last edited by Scott; 01-27-2011 at 01:01 PM..
Reason: Code tags, please...
Your propositions don't works because I need to put the result of my query in a variable (result). After I will make an 'foreach' foreache line that returns my query (nesteed loop).
for using find in place of my expression, I'm not sure that I will have the same result.
my Algo is :
- I read the file contains the extension's list.
- for each extension, I look for all the files in my target directory
- for each ligne of my result (each files), I move it to another directory (that is the point I haven't specify).
You see...
I've make the test with find, and the issue is the same :
thanks
Last edited by Scott; 01-27-2011 at 01:13 PM..
Reason: Code tags, please...
I'm a bit wary of when people say "no really, I honestly need to cram an unlimited number of results into one single variable and it won't work any other way". This is usually just a bad programming habit, not an actual need.
Consider:
This lets you process it one name at a time so you don't need to worry about shell limits.
Cramming unlimited numbers of arguments is a bad idea for many reasons:
What happens if you get a file named "stuff to do.ext"? Stuff it into one giant list and it'd become three files, "stuff", "to", "do.ext".
Many shells have surprisingly small limits on the maximum length you can fit in one shell variable. As the number of files gets large it'll break when you least expect it.
Using pipes to process names one at a time avoids these both.
Actually, you can simplify that using the -exec feature of find:
...and if you're using Linux, you can use the -t feature of mv and the + feature of find, which will let it move multiple files with one command very quickly:
---------- Post updated at 10:40 AM ---------- Previous update was at 10:20 AM ----------
Quote:
Originally Posted by skubann
I've make the test with find, and the issue is the same :
result=`find ../FILES/ -name "*.$ext"` don't parse the ext variable.
thanks
find works. Something else is wrong.
Have you tried one of my solutions?
Last edited by Corona688; 01-27-2011 at 12:27 PM..
I test your code, and he don't works to (I suppose for the same issue) : the parsing problem.
I do the same test. I replace ${EXT} by txt and then he return me the four results I waiting for.
otherwise, you perfectly right the way I do my code... sorry. I keep your algorithm, better than mine
I test your code, and he don't works to (I suppose for the same issue) : the parsing problem.
I think you're assuming the conclusion. I tested find like that on my system and it works fine. Try this test script (warning, it creates files and directories in the current directory!)
Can you please show us the results of ls -R ../FILES/ | grep "ext" where "ext" is one of the extensions you're looking for. Maybe your path is a little off or something, preventing find from working.
Also show us what your extensions file looks like. Maybe it's not what we think it is.
Also post that complete loop as you have it now, maybe we can spot a mistake.
Last edited by Corona688; 01-27-2011 at 12:54 PM..
this is a copy of my code :
as you will see, it's the same to you. But he doesn't work.
you know, I have to go now. I will think about this night...
Tomorrow, I 'll see with a clear mind.
I have this file (1.txt):
>sample
TCGGCCCGJOHNTTTTGCGGGCCGCATTGTCGCCAGGCGCDOEGGGGTTTGCGATCGCCACGGGGCTGATGGTGGCGACCCGCTGCACCCGG
I am using the following script to "trim" the sequence
awk '{gsub(/^.*JOHN|DOE.*$/,"",$0)} 1'
This is the output:
>sample
TTTTGCGGGCCGCATTGTCGCCAGGCGC
... (6 Replies)
Hi All,
My files(.csv) are created in download path.
All the files files are having footer with count of rows or may be blank.
When i am trying to put this below code in shell script and run it, the row_num is not getting assigned,
but works correctly on command prompt.
I am trying to put this... (2 Replies)
Hi All,
I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command.
The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Hi,
I am doing an AWK in ksh as below with the string to search to be read from variable but for some reason there is no output. It works when I hard code it.
awk 'substr($0,22,6)=="${VAR}"' XXX.txt' >YYY.txt
On reading other posts I tried below option,
'substr($0,22,6)=="/"${VAR}/""'
... (3 Replies)
Hello,
I logged in to the unix solaris with my user name and then I again logged in with the sudo bash -l command
now when I do echo $PATH
It shows me => /usr/bin:/usr/local/bin:/usr/bin/usr/sbin:/usr/ucb:/usr/local/bin
How do i find out where is this file located for setting the... (3 Replies)
Friends,
I want to write a script. The logic follows
1. Script starts
2. SSH to Remote Machine and check whether /home/testUser dir is there or not.
3. If it is there, am assigning a value to a variable. else not
4. If the variable is set, the do the copy from remote machine to my local... (2 Replies)
Hi all,
Something funny happen with this code:
EXIST=`ssh batch@190.2.332.234 'if ; then echo 0; else echo 1 ; fi'`
echo $EXIST
Above code will display "1".
The value of remotePath is /home/batch
The value of fileName is sample.txt
=========================================
... (1 Reply)
The code im having problems with is highlighted in red, upon selecting option 2 on the main menu (highlighted green) my echo "NETWORK CONNECTIVITY" command seems to get overlooked and the resulting output is "Thank you for using the Operator Administrative Tool." being displayed. Can anyone tell me... (2 Replies)
Hi All,
i am new to unix..
i have an issue with my unix script...let me explain the task that i want to make script....
i prepared script which will connect data base from my linux box using sqlplus cmd...
however in that i want to use the variable like below..
select * from... (0 Replies)
#!/bin/ksh
VAR_ONE=HELLO
TEMP=ONE
echo $VAR_${TEMP}
## Output is: ONE
Hi, I want the output to echo HELLO and not ONE as the above script does. I know I am missing something with dollar substitution. Can anyone help me out ?
Thanks.
Cal (4 Replies)