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;








13















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



  1. parse a european standard to extract a test sequence


  2. convert the text encodings to utf8


  3. process the result with the the awk routine that was provided to me on the post above.


  4. 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









share|improve this question



















  • 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


















13















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



  1. parse a european standard to extract a test sequence


  2. convert the text encodings to utf8


  3. process the result with the the awk routine that was provided to me on the post above.


  4. 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









share|improve this question



















  • 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














13












13








13


3






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



  1. parse a european standard to extract a test sequence


  2. convert the text encodings to utf8


  3. process the result with the the awk routine that was provided to me on the post above.


  4. 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









share|improve this question
















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



  1. parse a european standard to extract a test sequence


  2. convert the text encodings to utf8


  3. process the result with the the awk routine that was provided to me on the post above.


  4. 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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













  • 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











1 Answer
1






active

oldest

votes


















15














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 so
awk 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.






share|improve this answer

























  • 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












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
);



);













draft saved

draft discarded


















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









15














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 so
awk 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.






share|improve this answer

























  • 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
















15














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 so
awk 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.






share|improve this answer

























  • 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














15












15








15







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 so
awk 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.






share|improve this answer















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 so
awk 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.







share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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


















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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

Popular posts from this blog

Mobil Contents History Mobil brands Former Mobil brands Lukoil transaction Mobil UK Mobil Australia Mobil New Zealand Mobil Greece Mobil in Japan Mobil in Canada Mobil Egypt See also References External links Navigation menuwww.mobil.com"Mobil Corporation"the original"Our Houston campus""Business & Finance: Socony-Vacuum Corp.""Popular Mechanics""Lubrite Technologies""Exxon Mobil campus 'clearly happening'""Toledo Blade - Google News Archive Search""The Lion and the Moose - How 2 Executives Pulled off the Biggest Merger Ever""ExxonMobil Press Release""Lubricants""Archived copy"the original"Mobil 1™ and Mobil Super™ motor oil and synthetic motor oil - Mobil™ Motor Oils""Mobil Delvac""Mobil Industrial website""The State of Competition in Gasoline Marketing: The Effects of Refiner Operations at Retail""Mobil Travel Guide to become Forbes Travel Guide""Hotel Rankings: Forbes Merges with Mobil"the original"Jamieson oil industry history""Mobil news""Caltex pumps for control""Watchdog blocks Caltex bid""Exxon Mobil sells service station network""Mobil Oil New Zealand Limited is New Zealand's oldest oil company, with predecessor companies having first established a presence in the country in 1896""ExxonMobil subsidiaries have a business history in New Zealand stretching back more than 120 years. We are involved in petroleum refining and distribution and the marketing of fuels, lubricants and chemical products""Archived copy"the original"Exxon Mobil to Sell Its Japanese Arm for $3.9 Billion""Gas station merger will end Esso and Mobil's long run in Japan""Esso moves to affiliate itself with PC Optimum, no longer Aeroplan, in loyalty point switch""Mobil brand of gas stations to launch in Canada after deal for 213 Loblaws-owned locations""Mobil Nears Completion of Rebranding 200 Loblaw Gas Stations""Learn about ExxonMobil's operations in Egypt""Petrol and Diesel Service Stations in Egypt - Mobil"Official websiteExxon Mobil corporate websiteMobil Industrial official websiteeeeeeeeDA04275022275790-40000 0001 0860 5061n82045453134887257134887257

Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant

My Life (Mary J. Blige album) Contents Background Critical reception Accolades Commercial performance Track listing Personnel Charts Certifications See also References External links Navigation menu"1. Mary J Blige, My Life - The 50 Best R&B albums of the '90s""American album certifications – Mary J. Blige – My Life""Mary J. Blige's My Life LP (1994) revisited with co-producer Chucky Thompson | Return To The Classics"the original"Key Tracks: Mary J. Blige's My Life""My Life – Mary J. Blige""Worth The Wait""My Life""Forget '411,' Mary J., Better Call 911""Spins"My Life AccoladesThe 500 Greatest Albums of All TimeTime's All-TIME 100 Albums"Top RPM Albums: Issue chartid""Dutchcharts.nl – Mary J. Blige – My Life""Mary J. Blige | Artist | Official Charts""Mary J. Blige Chart History (Billboard 200)""Mary J. Blige Chart History (Top R&B/Hip-Hop Albums)""Canadian album certifications – Mary J Blige – My Life""British album certifications – Mary J Blige – My Life""American album certifications – Mary J Blige – My Life"My LifeMy Life accoladesee