well... your original version would have had the same issue. This is a limitation of this approach to begin with.
Try or ghostdog74's post above:
I had already tryed, but: It works using it "stand-alone", for example:
MacBook-di-Mirko:unix mirko$ find /Users/mirko/Unix -type f -name '*.txt'
/Users/mirko/Unix/file.txt
/Users/mirko/Unix/lettera.txt
/Users/mirko/Unix/motion/README.txt
/Users/mirko/Unix/Radio Ga Ga.txt
/Users/mirko/Unix/Save Me.txt
/Users/mirko/Unix/Seven Seas Of Rhye.txt
It doesn't work using it in a for, for example: MacBook-di-Mirko:unix mirko$ ./test.sh
/Users/mirko/Unix/file.txt
/Users/mirko/Unix/lettera.txt
/Users/mirko/Unix/motion/README.txt /Users/mirko/Unix/Radio
Ga
Ga.txt /Users/mirko/Unix/Save
Me.txt
/Users/mirko/Unix/Seven
Seas
Of
Rhye.txt
It split the file names with one or more spaces in their names
MacBook-di-Mirko:unix mirko$ ./test.sh
/Users/mirko/Unix/file.txt
/Users/mirko/Unix/lettera.txt
/Users/mirko/Unix/motion/README.txt /Users/mirko/Unix/Radio
Ga
Ga.txt /Users/mirko/Unix/Save
Me.txt
/Users/mirko/Unix/Seven
Seas
Of
Rhye.txt
It split the file names with one or more spaces in their names
PS: the script is:
As ever, you need to put your variables in double quotes. Just get in the habit of doing that always and you will avoid a lot of surprises.
However, the "for" will also split on whitespace, so you need to do that differently, too.
Or, you can fidget with the value of $IFS to make space not be a token separator, but that's not something I particularly recommend.
(There are still some pitfalls. If you had files with backslashes in their names, those would be tricky even with this code.)
I had already tryed, but: It works using it "stand-alone", for example:
MacBook-di-Mirko:unix mirko$ find /Users/mirko/Unix -type f -name '*.txt'
/Users/mirko/Unix/file.txt
/Users/mirko/Unix/lettera.txt
/Users/mirko/Unix/motion/README.txt
/Users/mirko/Unix/Radio Ga Ga.txt
/Users/mirko/Unix/Save Me.txt
/Users/mirko/Unix/Seven Seas Of Rhye.txt
It doesn't work using it in a for, for example: MacBook-di-Mirko:unix mirko$ ./test.sh
/Users/mirko/Unix/file.txt
/Users/mirko/Unix/lettera.txt
/Users/mirko/Unix/motion/README.txt /Users/mirko/Unix/Radio
Ga
Ga.txt /Users/mirko/Unix/Save
Me.txt
/Users/mirko/Unix/Seven
Seas
Of
Rhye.txt
It split the file names with one or more spaces in their names
PS: the script is:
what do you want to do with those *.txt files it finds?? I believe you don't just want to echo their names out. If that's the case, no need for a for loop/while loop because the find command displays to stdout. Otherwise, you can use -exec or xargs for simple task, or coupled with while loop for more complicated tasks
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi
Is it possible to get the below code working.?
cmd="grep 'Name:' |awk -F' ' '{print $2}'|xargs -i basename {}"
echo $cmd
(
rman target / <<EOF1
LIST COPY ;
exit
EOF1
) | `$cmd`
in nutshell I want to be able to preset cmd as depending on script flow it can be... (2 Replies)
Hello.
Following recommendations for one of my threads, this is working perfectly :
#!/bin/bash
CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" )
Now I need a grep success for some thing like :
#!/bin/bash
CNT=$( grep -c -e "some text_1... (4 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi all,
can any one suggest me the script to grep multiple strings from ps -ef
pls correct the below script . its not working/
i want to print OK if all the below process are running in my solaris system. else i want to print NOT OK.
bash-3.00$ ps -ef | grep blu
lscpusr 48 42 ... (11 Replies)
Hi all,
grep '\~' b | awk '{print $1","$3}' | sed -e 's/~//g'
Iam using above command for some report...
can this be done using any one of them either sed or awk or grep... (3 Replies)
Hi Guys,
I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys.
MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' `
Harby. (4 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)