stupid question: awk and space prob
Hi,
I am bumping on a stupid one :-) I have in my folder ZURICK .htm ZURICK2 .htm ZURICK3 .htm Code:
ls *.htm | awk ' { print $0 ; file =" "$0" "; system( " cat " file ) } ' Code:
ZURICK .htm -- same for this with sh: Quote:
this not working either : Quote:
By the way, it is with cygwin |
Hi,
Your missing, or misplacing, double quotes: This: ls *.htm | awk ' { print $0 ; file =" "$0" "; system( " cat " file ) } ' Should be this: ls *.htm | awk ' { print $0 ; file =" \""$0"\" "; system( " cat " file ) } ' This puts literal double quotes around $0, making it part of file. This: for each in "$File" ; do echo "$each" ; cat "$each" ; done Should be: for each in $File; do echo $each; cat "$each" ;done The double quotes around $File should not be there. Otherwise $File would have one entry only, namely the whole string that the ls command came up with. BTW: Why use: File=`echo "$(ls *.htm)" ? Wouldn't: File=*htm be easier or File="`ls *htm`" if you want more readability. Hope this helps. |
Hi.
Probably better with Code:
for go in *.htm Edit. Gah! Beaten to it. |
What are you trying to do? Remove the spaces?
Joel |
Thanks a lot lot guys !!! that's so helpful
Now I get error msg when typign this: Code:
ls *.htm | awk ' { file =" \""$0"\" "; system( "./getthefollowinglinkinto.sh " file ) ; next } ' Code:
ls *.htm | awk ' { file =" \""$0"\" "; system( " sh getthefollowinglinkinto.sh " file ) ; next } ' Not easy ... but I am trying hard ---- better, when this: Quote:
I get : Quote:
|
Hi,
What is it you are trying to do (in general)? I'm asking because all that is done in getthelinkinto.sh can also be done inside the script that calls getthelinkinto.sh. Seems like a hard way to do things. |
Quote:
In the getthelinkinto.sh, there is: Code:
#!/bin/sh For the moment, just bit of training with spaces, ... since I made already a script but got it wrong with spaces problems. I removed all and started from begining to learn space stuffs. THanks a lot for support. Btw, awk rocks really !! Cool Link: http://www.grymoire.com/Unix/Awk.html |
Quote:
Code:
cat *htm Code:
awk '1' *htm Code:
awk 'BEGIN{n=FILENAME} |
same problem ... this is not working :(
Code:
#!/bin/bash |
Fix it up how you like, this works.
Code:
find -name '*.pdf'|while read each;do cat "$each";done |
Quote:
Code:
find -name .... | xargs cat |
All times are GMT -5. The time now is 05:32 AM. |