I'm having some difficulty with running in the AppleScript and Shell scripts. Actually, the URL is set as the variable URL And it will be fed into a shell script:
do shell script "cd dir; cat file | grep -v '^ http' | sed 's / ^ /" & amp; Variable url & amp; "/ '& Gt; urlsxy.txt" This is not working - I do not find anything in my output file, I guess, that is the unsecad character. Worse, I can not know ahead of time how the URL will look, and in this way I can not set any way to keep backslash in the form of a runaway. When, instead of using variableUrl , I just insert dummy text, I have no problem. This, for example, works fine: do shell script "cd dir; cat file | grep -v '^ http' | sed 's / ^ / dummytext /' & gt; ; Urlsxy.txt " Right now, I have also tried to convert the URL into a bash variable ...
sed 's / ^ / "$ BASHVAR \\ / g But this could also be unsuccessful, possibly for the same reason. Can any organization tell me whether to solve this problem? The remedy is, or if any
I am very new to it, and as you can see Only familiar with the basics.
assuming that you want to replace this symbol "^" , Then it should work:
sed "s / ^ /` printf '% q' "$ {BASHVAR}" / g " Or, to insert $ Bassworver content at the beginning of each line:
sed "s / ^ /` printf '% q' "$ {BASHVAR}" / g " Note: I am the backtix (`) portal around the printf statement, because they show the results of executing the shell and the result is a result Print: '% q' "$ {BASHVAR}"
EDIT: To additional restrictions (see comments for this answer) Consider that a forward slash can be displayed in $ BASHVAR, then an alternative solution is to use a different character which separates the forward slash as a separator for SAD. Two examples:
sed @ ^ @ printf '% q' "$ {BASHVAR}" `@ g 'sed" s # ^ # printf'% q '"$ {BASHVAR}" ` # G "
No comments:
Post a Comment