How to integrate a multiline awk script in a shell script Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionHow to parse a file to extract 3 digits numbers kept in a “group number”How to run a shell script containing an awk commandMultiline shell script comments - how does this work?AWK: Passing shell variables to awkUsing variable with awk -v in a shell scriptUnable to replace variable in shell script using awkHow to integrate awk parameters in awk range patternhow to split multiline records by awk?Shell Script - Awk Optimizationawk — change after multiline contextHow to call another shell script within AWK
Unexpected result with right shift after bitwise negation
Estimated State payment too big --> money back; + 2018 Tax Reform
Autumning in love
Direct Experience of Meditation
Complexity of many constant time steps with occasional logarithmic steps
Can a non-EU citizen traveling with me come with me through the EU passport line?
Windows 10: How to Lock (not sleep) laptop on lid close?
What loss function to use when labels are probabilities?
Can the prologue be the backstory of your main character?
How do I automatically answer y in bash script?
What to do with post with dry rot?
When is phishing education going too far?
How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time
How do I keep my slimes from escaping their pens?
Is above average number of years spent on PhD considered a red flag in future academia or industry positions?
How to say that you spent the night with someone, you were only sleeping and nothing else?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
How can players take actions together that are impossible otherwise?
Single author papers against my advisor's will?
Working around an AWS network ACL rule limit
Active filter with series inductor and resistor - do these exist?
What can I do if my MacBook isn’t charging but already ran out?
Antler Helmet: Can it work?
How does modal jazz use chord progressions?
How to integrate a multiline awk script in a shell script
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionHow to parse a file to extract 3 digits numbers kept in a “group number”How to run a shell script containing an awk commandMultiline shell script comments - how does this work?AWK: Passing shell variables to awkUsing variable with awk -v in a shell scriptUnable to replace variable in shell script using awkHow to integrate awk parameters in awk range patternhow to split multiline records by awk?Shell Script - Awk Optimizationawk — change after multiline contextHow to call another shell script within AWK
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
My question is a continuation of
How to parse a file to extract 3 digits numbers kept in a "group number"
I am trying to integrate in a single shell script a series of commands that
parse a european standard to extract a test sequence
convert the text encodings to utf8
process the result with the the awk routine that was provided to me on the post above.
save the content in a destination file
I have tentatively written the script below. I am able to achieve only step 1
and step 4
, but neither step 2
nor step 3
. I wonder if intermediate (temporary) file(s) should be created. I have tried to store the output of intermediate steps into variables, but without success. Any help also would be helpul regarding possible mistakes and the best way to do this.
#!/bin/bash
# creating the Latex code for a test procedure
awkcommand= "/usr/bin/awk
'
$1 == "Group" printf("\section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("\subsection%s n\TestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
"
sourcefolder="/Users/yves/Desktop/Test-folder-parsing/"
sourcefile="NFEN3545-001.pdf"
destfile="Latex-code.tex"
destfolder=$sourcefolder
destinationfilepath=$destfolder$destfile
extractioncmd="/usr/local/bin/pdftotext -layout -f 54 -l 54"
modifier=" -"
#textencodingcmd="/usr/bin/iconv -f L1 -t UTF-8" # Needed but not used
$extractioncmd $sourcefolder$sourcefile $modifier > $destinationfilepath
exit 0
shell-script awk
add a comment |
My question is a continuation of
How to parse a file to extract 3 digits numbers kept in a "group number"
I am trying to integrate in a single shell script a series of commands that
parse a european standard to extract a test sequence
convert the text encodings to utf8
process the result with the the awk routine that was provided to me on the post above.
save the content in a destination file
I have tentatively written the script below. I am able to achieve only step 1
and step 4
, but neither step 2
nor step 3
. I wonder if intermediate (temporary) file(s) should be created. I have tried to store the output of intermediate steps into variables, but without success. Any help also would be helpul regarding possible mistakes and the best way to do this.
#!/bin/bash
# creating the Latex code for a test procedure
awkcommand= "/usr/bin/awk
'
$1 == "Group" printf("\section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("\subsection%s n\TestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
"
sourcefolder="/Users/yves/Desktop/Test-folder-parsing/"
sourcefile="NFEN3545-001.pdf"
destfile="Latex-code.tex"
destfolder=$sourcefolder
destinationfilepath=$destfolder$destfile
extractioncmd="/usr/local/bin/pdftotext -layout -f 54 -l 54"
modifier=" -"
#textencodingcmd="/usr/bin/iconv -f L1 -t UTF-8" # Needed but not used
$extractioncmd $sourcefolder$sourcefile $modifier > $destinationfilepath
exit 0
shell-script awk
2
Saving commands to shell variable is an approach leading to many troubles.
– enzotib
Aug 11 '13 at 9:51
1
What he said, in spades. mywiki.wooledge.org/BashFAQ/050
– tripleee
Aug 11 '13 at 13:08
@Anthon. How did you make a nice list of the commands? I had tried unsuccessfully, and I have the same problem in my second comment below, just worse....
– Yves
Aug 11 '13 at 15:16
@Yves. Empty line 1. xxx newline/empty line 2. .. etc. But the easiest is to click on edit once more and look at the mark-up. On the top-right you might have an orange question mark, which explains on the formatting (you might not have that depending on your reputation) You can always cancel the edit. In comments however you have far less formatting capabilities (click on help under the[Add Comment]
button to see what is allowed in comments). (In that case you might be better of updating your original post).
– Anthon
Aug 11 '13 at 16:02
add a comment |
My question is a continuation of
How to parse a file to extract 3 digits numbers kept in a "group number"
I am trying to integrate in a single shell script a series of commands that
parse a european standard to extract a test sequence
convert the text encodings to utf8
process the result with the the awk routine that was provided to me on the post above.
save the content in a destination file
I have tentatively written the script below. I am able to achieve only step 1
and step 4
, but neither step 2
nor step 3
. I wonder if intermediate (temporary) file(s) should be created. I have tried to store the output of intermediate steps into variables, but without success. Any help also would be helpul regarding possible mistakes and the best way to do this.
#!/bin/bash
# creating the Latex code for a test procedure
awkcommand= "/usr/bin/awk
'
$1 == "Group" printf("\section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("\subsection%s n\TestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
"
sourcefolder="/Users/yves/Desktop/Test-folder-parsing/"
sourcefile="NFEN3545-001.pdf"
destfile="Latex-code.tex"
destfolder=$sourcefolder
destinationfilepath=$destfolder$destfile
extractioncmd="/usr/local/bin/pdftotext -layout -f 54 -l 54"
modifier=" -"
#textencodingcmd="/usr/bin/iconv -f L1 -t UTF-8" # Needed but not used
$extractioncmd $sourcefolder$sourcefile $modifier > $destinationfilepath
exit 0
shell-script awk
My question is a continuation of
How to parse a file to extract 3 digits numbers kept in a "group number"
I am trying to integrate in a single shell script a series of commands that
parse a european standard to extract a test sequence
convert the text encodings to utf8
process the result with the the awk routine that was provided to me on the post above.
save the content in a destination file
I have tentatively written the script below. I am able to achieve only step 1
and step 4
, but neither step 2
nor step 3
. I wonder if intermediate (temporary) file(s) should be created. I have tried to store the output of intermediate steps into variables, but without success. Any help also would be helpul regarding possible mistakes and the best way to do this.
#!/bin/bash
# creating the Latex code for a test procedure
awkcommand= "/usr/bin/awk
'
$1 == "Group" printf("\section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("\subsection%s n\TestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
"
sourcefolder="/Users/yves/Desktop/Test-folder-parsing/"
sourcefile="NFEN3545-001.pdf"
destfile="Latex-code.tex"
destfolder=$sourcefolder
destinationfilepath=$destfolder$destfile
extractioncmd="/usr/local/bin/pdftotext -layout -f 54 -l 54"
modifier=" -"
#textencodingcmd="/usr/bin/iconv -f L1 -t UTF-8" # Needed but not used
$extractioncmd $sourcefolder$sourcefile $modifier > $destinationfilepath
exit 0
shell-script awk
shell-script awk
edited 18 hours ago
Rui F Ribeiro
42.1k1483142
42.1k1483142
asked Aug 11 '13 at 8:59
YvesYves
185114
185114
2
Saving commands to shell variable is an approach leading to many troubles.
– enzotib
Aug 11 '13 at 9:51
1
What he said, in spades. mywiki.wooledge.org/BashFAQ/050
– tripleee
Aug 11 '13 at 13:08
@Anthon. How did you make a nice list of the commands? I had tried unsuccessfully, and I have the same problem in my second comment below, just worse....
– Yves
Aug 11 '13 at 15:16
@Yves. Empty line 1. xxx newline/empty line 2. .. etc. But the easiest is to click on edit once more and look at the mark-up. On the top-right you might have an orange question mark, which explains on the formatting (you might not have that depending on your reputation) You can always cancel the edit. In comments however you have far less formatting capabilities (click on help under the[Add Comment]
button to see what is allowed in comments). (In that case you might be better of updating your original post).
– Anthon
Aug 11 '13 at 16:02
add a comment |
2
Saving commands to shell variable is an approach leading to many troubles.
– enzotib
Aug 11 '13 at 9:51
1
What he said, in spades. mywiki.wooledge.org/BashFAQ/050
– tripleee
Aug 11 '13 at 13:08
@Anthon. How did you make a nice list of the commands? I had tried unsuccessfully, and I have the same problem in my second comment below, just worse....
– Yves
Aug 11 '13 at 15:16
@Yves. Empty line 1. xxx newline/empty line 2. .. etc. But the easiest is to click on edit once more and look at the mark-up. On the top-right you might have an orange question mark, which explains on the formatting (you might not have that depending on your reputation) You can always cancel the edit. In comments however you have far less formatting capabilities (click on help under the[Add Comment]
button to see what is allowed in comments). (In that case you might be better of updating your original post).
– Anthon
Aug 11 '13 at 16:02
2
2
Saving commands to shell variable is an approach leading to many troubles.
– enzotib
Aug 11 '13 at 9:51
Saving commands to shell variable is an approach leading to many troubles.
– enzotib
Aug 11 '13 at 9:51
1
1
What he said, in spades. mywiki.wooledge.org/BashFAQ/050
– tripleee
Aug 11 '13 at 13:08
What he said, in spades. mywiki.wooledge.org/BashFAQ/050
– tripleee
Aug 11 '13 at 13:08
@Anthon. How did you make a nice list of the commands? I had tried unsuccessfully, and I have the same problem in my second comment below, just worse....
– Yves
Aug 11 '13 at 15:16
@Anthon. How did you make a nice list of the commands? I had tried unsuccessfully, and I have the same problem in my second comment below, just worse....
– Yves
Aug 11 '13 at 15:16
@Yves. Empty line 1. xxx newline/empty line 2. .. etc. But the easiest is to click on edit once more and look at the mark-up. On the top-right you might have an orange question mark, which explains on the formatting (you might not have that depending on your reputation) You can always cancel the edit. In comments however you have far less formatting capabilities (click on help under the
[Add Comment]
button to see what is allowed in comments). (In that case you might be better of updating your original post).– Anthon
Aug 11 '13 at 16:02
@Yves. Empty line 1. xxx newline/empty line 2. .. etc. But the easiest is to click on edit once more and look at the mark-up. On the top-right you might have an orange question mark, which explains on the formatting (you might not have that depending on your reputation) You can always cancel the edit. In comments however you have far less formatting capabilities (click on help under the
[Add Comment]
button to see what is allowed in comments). (In that case you might be better of updating your original post).– Anthon
Aug 11 '13 at 16:02
add a comment |
1 Answer
1
active
oldest
votes
You can store the code passed to /usr/bin/awk
in a variable and/usr/bin/awk
in a separate variable like so (untested):
awk=/usr/bin/awk
awkcommand='
$1 == "Group" printf("section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("subsection%s nTestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
Usage:
$awk "$awkcommand"
Note that I changed the double quotation marks to single quotation marks.
Within double quotation marks, $i
is substituted by the contents of the shell
variable i
. Within single quotation marks, it is a literal $i
, which is
what awk
expects to see.
Also, you weren't escaping the double quotation marks within the string soawk
never saw
$1 == "Group" printf("section%s %dn", $1, $2); next
Instead, it saw
<contents of shell $1> == Group printf(section%s %dn, <contents of shell $1>, <contents of shell $2>); next
If $1
and $2
were empty, awk
saw
== Group printf(section%s %dn, , ); next
Are you sure storing the command location is necessary? You can usually depend
on finding awk
within a directory in your user's path. If you don't use the
full path to awk
, there is no reason to parameterize awk
.
Thanks. I have now been able to make the awk command work: $extractioncmd $sourcefolder$sourcefile$modifier | $awk "$awkcommand" > $destinationfilepath However, trying to do the same wiht iconv does not work: iconv=/usr/bin/iconv param=" -f L1 -t UTF-8" $extractioncmd $sourcefolder$sourcefile$modifier | $iconv "$param" | $awk "$awkcommand" > $destinationfilepath # does not work, the target file is empty. BTW, the reason I used the full path was that I read this as a recommended practice in a tutorial.
– Yves
Aug 11 '13 at 15:09
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f86329%2fhow-to-integrate-a-multiline-awk-script-in-a-shell-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can store the code passed to /usr/bin/awk
in a variable and/usr/bin/awk
in a separate variable like so (untested):
awk=/usr/bin/awk
awkcommand='
$1 == "Group" printf("section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("subsection%s nTestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
Usage:
$awk "$awkcommand"
Note that I changed the double quotation marks to single quotation marks.
Within double quotation marks, $i
is substituted by the contents of the shell
variable i
. Within single quotation marks, it is a literal $i
, which is
what awk
expects to see.
Also, you weren't escaping the double quotation marks within the string soawk
never saw
$1 == "Group" printf("section%s %dn", $1, $2); next
Instead, it saw
<contents of shell $1> == Group printf(section%s %dn, <contents of shell $1>, <contents of shell $2>); next
If $1
and $2
were empty, awk
saw
== Group printf(section%s %dn, , ); next
Are you sure storing the command location is necessary? You can usually depend
on finding awk
within a directory in your user's path. If you don't use the
full path to awk
, there is no reason to parameterize awk
.
Thanks. I have now been able to make the awk command work: $extractioncmd $sourcefolder$sourcefile$modifier | $awk "$awkcommand" > $destinationfilepath However, trying to do the same wiht iconv does not work: iconv=/usr/bin/iconv param=" -f L1 -t UTF-8" $extractioncmd $sourcefolder$sourcefile$modifier | $iconv "$param" | $awk "$awkcommand" > $destinationfilepath # does not work, the target file is empty. BTW, the reason I used the full path was that I read this as a recommended practice in a tutorial.
– Yves
Aug 11 '13 at 15:09
add a comment |
You can store the code passed to /usr/bin/awk
in a variable and/usr/bin/awk
in a separate variable like so (untested):
awk=/usr/bin/awk
awkcommand='
$1 == "Group" printf("section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("subsection%s nTestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
Usage:
$awk "$awkcommand"
Note that I changed the double quotation marks to single quotation marks.
Within double quotation marks, $i
is substituted by the contents of the shell
variable i
. Within single quotation marks, it is a literal $i
, which is
what awk
expects to see.
Also, you weren't escaping the double quotation marks within the string soawk
never saw
$1 == "Group" printf("section%s %dn", $1, $2); next
Instead, it saw
<contents of shell $1> == Group printf(section%s %dn, <contents of shell $1>, <contents of shell $2>); next
If $1
and $2
were empty, awk
saw
== Group printf(section%s %dn, , ); next
Are you sure storing the command location is necessary? You can usually depend
on finding awk
within a directory in your user's path. If you don't use the
full path to awk
, there is no reason to parameterize awk
.
Thanks. I have now been able to make the awk command work: $extractioncmd $sourcefolder$sourcefile$modifier | $awk "$awkcommand" > $destinationfilepath However, trying to do the same wiht iconv does not work: iconv=/usr/bin/iconv param=" -f L1 -t UTF-8" $extractioncmd $sourcefolder$sourcefile$modifier | $iconv "$param" | $awk "$awkcommand" > $destinationfilepath # does not work, the target file is empty. BTW, the reason I used the full path was that I read this as a recommended practice in a tutorial.
– Yves
Aug 11 '13 at 15:09
add a comment |
You can store the code passed to /usr/bin/awk
in a variable and/usr/bin/awk
in a separate variable like so (untested):
awk=/usr/bin/awk
awkcommand='
$1 == "Group" printf("section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("subsection%s nTestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
Usage:
$awk "$awkcommand"
Note that I changed the double quotation marks to single quotation marks.
Within double quotation marks, $i
is substituted by the contents of the shell
variable i
. Within single quotation marks, it is a literal $i
, which is
what awk
expects to see.
Also, you weren't escaping the double quotation marks within the string soawk
never saw
$1 == "Group" printf("section%s %dn", $1, $2); next
Instead, it saw
<contents of shell $1> == Group printf(section%s %dn, <contents of shell $1>, <contents of shell $2>); next
If $1
and $2
were empty, awk
saw
== Group printf(section%s %dn, , ); next
Are you sure storing the command location is necessary? You can usually depend
on finding awk
within a directory in your user's path. If you don't use the
full path to awk
, there is no reason to parameterize awk
.
You can store the code passed to /usr/bin/awk
in a variable and/usr/bin/awk
in a separate variable like so (untested):
awk=/usr/bin/awk
awkcommand='
$1 == "Group" printf("section%s %dn", $1, $2); next
title = sep = ""
for (i=1; i<=NF; i++)
if ($i ~ /^[0-9][0-9][0-9]$/)
printf("subsection%s nTestDetails%dn", title, $i)
break
else
title = title sep $i
sep = FS
'
Usage:
$awk "$awkcommand"
Note that I changed the double quotation marks to single quotation marks.
Within double quotation marks, $i
is substituted by the contents of the shell
variable i
. Within single quotation marks, it is a literal $i
, which is
what awk
expects to see.
Also, you weren't escaping the double quotation marks within the string soawk
never saw
$1 == "Group" printf("section%s %dn", $1, $2); next
Instead, it saw
<contents of shell $1> == Group printf(section%s %dn, <contents of shell $1>, <contents of shell $2>); next
If $1
and $2
were empty, awk
saw
== Group printf(section%s %dn, , ); next
Are you sure storing the command location is necessary? You can usually depend
on finding awk
within a directory in your user's path. If you don't use the
full path to awk
, there is no reason to parameterize awk
.
edited Aug 11 '13 at 14:01
answered Aug 11 '13 at 13:54
user26112
Thanks. I have now been able to make the awk command work: $extractioncmd $sourcefolder$sourcefile$modifier | $awk "$awkcommand" > $destinationfilepath However, trying to do the same wiht iconv does not work: iconv=/usr/bin/iconv param=" -f L1 -t UTF-8" $extractioncmd $sourcefolder$sourcefile$modifier | $iconv "$param" | $awk "$awkcommand" > $destinationfilepath # does not work, the target file is empty. BTW, the reason I used the full path was that I read this as a recommended practice in a tutorial.
– Yves
Aug 11 '13 at 15:09
add a comment |
Thanks. I have now been able to make the awk command work: $extractioncmd $sourcefolder$sourcefile$modifier | $awk "$awkcommand" > $destinationfilepath However, trying to do the same wiht iconv does not work: iconv=/usr/bin/iconv param=" -f L1 -t UTF-8" $extractioncmd $sourcefolder$sourcefile$modifier | $iconv "$param" | $awk "$awkcommand" > $destinationfilepath # does not work, the target file is empty. BTW, the reason I used the full path was that I read this as a recommended practice in a tutorial.
– Yves
Aug 11 '13 at 15:09
Thanks. I have now been able to make the awk command work: $extractioncmd $sourcefolder$sourcefile$modifier | $awk "$awkcommand" > $destinationfilepath However, trying to do the same wiht iconv does not work: iconv=/usr/bin/iconv param=" -f L1 -t UTF-8" $extractioncmd $sourcefolder$sourcefile$modifier | $iconv "$param" | $awk "$awkcommand" > $destinationfilepath # does not work, the target file is empty. BTW, the reason I used the full path was that I read this as a recommended practice in a tutorial.
– Yves
Aug 11 '13 at 15:09
Thanks. I have now been able to make the awk command work: $extractioncmd $sourcefolder$sourcefile$modifier | $awk "$awkcommand" > $destinationfilepath However, trying to do the same wiht iconv does not work: iconv=/usr/bin/iconv param=" -f L1 -t UTF-8" $extractioncmd $sourcefolder$sourcefile$modifier | $iconv "$param" | $awk "$awkcommand" > $destinationfilepath # does not work, the target file is empty. BTW, the reason I used the full path was that I read this as a recommended practice in a tutorial.
– Yves
Aug 11 '13 at 15:09
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f86329%2fhow-to-integrate-a-multiline-awk-script-in-a-shell-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
-awk, shell-script
2
Saving commands to shell variable is an approach leading to many troubles.
– enzotib
Aug 11 '13 at 9:51
1
What he said, in spades. mywiki.wooledge.org/BashFAQ/050
– tripleee
Aug 11 '13 at 13:08
@Anthon. How did you make a nice list of the commands? I had tried unsuccessfully, and I have the same problem in my second comment below, just worse....
– Yves
Aug 11 '13 at 15:16
@Yves. Empty line 1. xxx newline/empty line 2. .. etc. But the easiest is to click on edit once more and look at the mark-up. On the top-right you might have an orange question mark, which explains on the formatting (you might not have that depending on your reputation) You can always cancel the edit. In comments however you have far less formatting capabilities (click on help under the
[Add Comment]
button to see what is allowed in comments). (In that case you might be better of updating your original post).– Anthon
Aug 11 '13 at 16:02