Timeline for echo line with var that contains few lines
Current License: CC BY-SA 4.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 25, 2018 at 6:15 | comment | added | Rom | After many attempts, it turns out that your last command is working. The shell in which the script is to be executed is proving to be a little strange in the way it works with EOF, but basically, the code works as expected via adb (sh). Thank you very much for your effort. | |
| Oct 24, 2018 at 21:49 | comment | added | Rom | Strangely enough I managed to get your last commands to work via adb shell with root access rights. I have seen on the internet that there is also the "EOD" option, but I have not found the difference between "EOF" and "EOD". It's amazing how much a shell can become a black cat. By any chance, is this your last method identical to the varname=(awk'{ print }' $var) command? | |
| Oct 24, 2018 at 21:49 | comment | added | Rom | Thanks for your efforts, after more than a dozen tests, it seems that the console in which my commands are executed does not like "EOF" very much, when executed by an unknown interpreter (I think it must be written in JAVA), I get "error "line: (last line): syntax error: unexpected end of file (expecting")". | |
| Oct 24, 2018 at 11:31 | comment | added | Stéphane Chazelas | See edit for a variant that calls one sqlite per query. | |
| Oct 24, 2018 at 11:30 | history | edited | Stéphane Chazelas | CC BY-SA 4.0 |
added 429 characters in body
|
| Oct 24, 2018 at 11:11 | comment | added | Rom | He also pointed out to me that the double quotation (") should not be used, but only the single quotation (') in order to avoid any ambiguity with the many special carachters contained in the text to be dealt with. His control didn't work. My last request would be the command that would fit in a single line, and would therefore write one or more sqlite command lines in the.sh file. That's why I proposed to use awk or other Linux applets. Also, i don't know how the s@...@...@) delimiter works, it's the same as the backslash \ or not ? | |
| Oct 24, 2018 at 11:11 | comment | added | Rom | Only one sqlite command must be executed at a time. A friend told me that it would be possible to do this action via the command if the use of sed became too complex. According to him, the command should be this: echo './sqlite $PLAY_DB_DIR/library.db "UPDATE ownership SET library_id = `\'u-wl\' where doc_id = \'$var\''";' > /folder/final.sh according to him since the variable contains in any case several lines, echo would then write as many lines as necessary by replacing $var with the following word contained in the variable. | |
| Oct 24, 2018 at 9:51 | comment | added | Stéphane Chazelas |
@Rom, see edit, it's a bit pointless to run one sqlite command per query. Your one has issues with variable expansion inside double quotes, and the fact that there are too many / in your s/../../ command (use a separate delimiter like s@...@...@).
|
|
| Oct 24, 2018 at 9:49 | history | edited | Stéphane Chazelas | CC BY-SA 4.0 |
added 252 characters in body
|
| Oct 24, 2018 at 9:40 | comment | added | Rom | So I'm going to do my "grumpy", but the sqlite command must remain the same as the one I initially noted. So the command should be: sed "s/.*/./sqlite $PLAY_DB_DIR/library.db "UPDATE ownership SET library_id = 'u-wl' where doc_id = '&';/" < $(cat $var) | final.sh because this command must to be writed into a shell file to be executed in Android environment. My one is good ? | |
| Oct 24, 2018 at 9:27 | comment | added | Stéphane Chazelas | @rom, see edit. | |
| Oct 24, 2018 at 9:27 | history | edited | Stéphane Chazelas | CC BY-SA 4.0 |
added 399 characters in body
|
| Oct 24, 2018 at 9:13 | comment | added | Rom | Thank you, i use the first or the second one command, but i have a problem with my text: ./sqlite $PLAY_DB_DIR/library.db "UPDATE ownership SET library_id = '\'u-wl\' where doc_id = \'pattern\''";' according to this: unix.stackexchange.com/questions/32907/… when i set backslashs for $.*/[]^ symbols, i get an bad pattern error from sed. I don't know where is my error(s). Maybe that it could be easier with awk or tr maybe ? | |
| Oct 24, 2018 at 6:18 | history | answered | Stéphane Chazelas | CC BY-SA 4.0 |