Awk no longer supported on android, need replacement [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-5
down vote

favorite












I got some old shell scripts which use awk to replace some tags in a file called awkLog to make it more readable. The current command looks something like this:



awk log.txt -f awkLog > output.txt


The purpose is that the script is going to write data in log.txt like cpu usage and so on and after that it would "parse" the data and write it to output.txt in the order as specified in awkLog.



I looked for some replacements but unfortnaly I have no experience with shell scripting... I found that some are using the command cut. But I can't see how to implement this in the shell scripts.



The code of awkLog:



BEGIN maxfree = 0
minfree = 10000000000
savailable += $1
sused += $2
sfree += $3
sshared += $4
sbuff += $5
if ( $3 > maxfree ) maxfree = $3
if ( $3 < minfree ) minfree = $3
END print "MEMORY"
mavailable = savailable/NR
print "(average) available : ", mavailable
print "average used : ", sused/NR
print "average free : ", sfree/NR
print "average shared : ", sshared/NR
print "average buff : ", sbuff/NR
print "free max : ", maxfree
print "free min : ", minfree
print "Minimum MEMORY usage : ", mavailable-maxfree, "K"
print "Maximum MEMORY usage : ", mavailable-minfree, "K"
print "Average MEMORY usage : ", mavailable-sfree/NR, "K"


Inside the log.txt it looks like this:



User 1%, System 3%, IOW 0%, IRQ 0%
User 6 + Nice 0 + Sys 14 + Idle 420 + IOW 0 + IRQ 0 + SIRQ 0 = 440

PID PR CPU% S #THR VSS RSS PCY UID Name
10488 3 2% R 1 3704K 1248K fg shell top


Like I said I'm NO expert nor experienced user of shell scripting as I have ZERO experience with this so any help would be very much appreciated.



But it didn't work, maybe someone of you can help me?
Thanks in advance







share|improve this question














closed as unclear what you're asking by muru, Ulrich Schwarz, Rui F Ribeiro, jasonwryan, Gilles Apr 11 at 6:57


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    It's kind of hard to offer concrete advice without seeing what awkLog does. Yes, maybe cut will be helpful, maybe rewrite to Perl or any other scripting language of choice.
    – Ulrich Schwarz
    Apr 11 at 6:48






  • 3




    Awk is still supported.
    – jasonwryan
    Apr 11 at 6:50






  • 2




    awk is still very much supported (as in "it's not deprecated"). If you need to replace awk with something else, you would have to investigate what the current script (awkLog) is doing and re-implement that in some other language or using some other parser. You mentioned "tags", does this mean that the current script is modifying XML? Without seeing what the awk script is doing, nobody can tell you what to replace it with.
    – Kusalananda
    Apr 11 at 6:54






  • 1




    Ok maybe to make things bit more clear I'm talking about the shell in an android phone. Maybe there it is no longer supported? Also the awkLog contains variables like $1, $2, ... and so on.
    – John
    Apr 11 at 7:00










  • Hi all I made the question a bit more clear as it was needed.
    – John
    Apr 11 at 7:32














up vote
-5
down vote

favorite












I got some old shell scripts which use awk to replace some tags in a file called awkLog to make it more readable. The current command looks something like this:



awk log.txt -f awkLog > output.txt


The purpose is that the script is going to write data in log.txt like cpu usage and so on and after that it would "parse" the data and write it to output.txt in the order as specified in awkLog.



I looked for some replacements but unfortnaly I have no experience with shell scripting... I found that some are using the command cut. But I can't see how to implement this in the shell scripts.



The code of awkLog:



BEGIN maxfree = 0
minfree = 10000000000
savailable += $1
sused += $2
sfree += $3
sshared += $4
sbuff += $5
if ( $3 > maxfree ) maxfree = $3
if ( $3 < minfree ) minfree = $3
END print "MEMORY"
mavailable = savailable/NR
print "(average) available : ", mavailable
print "average used : ", sused/NR
print "average free : ", sfree/NR
print "average shared : ", sshared/NR
print "average buff : ", sbuff/NR
print "free max : ", maxfree
print "free min : ", minfree
print "Minimum MEMORY usage : ", mavailable-maxfree, "K"
print "Maximum MEMORY usage : ", mavailable-minfree, "K"
print "Average MEMORY usage : ", mavailable-sfree/NR, "K"


Inside the log.txt it looks like this:



User 1%, System 3%, IOW 0%, IRQ 0%
User 6 + Nice 0 + Sys 14 + Idle 420 + IOW 0 + IRQ 0 + SIRQ 0 = 440

PID PR CPU% S #THR VSS RSS PCY UID Name
10488 3 2% R 1 3704K 1248K fg shell top


Like I said I'm NO expert nor experienced user of shell scripting as I have ZERO experience with this so any help would be very much appreciated.



But it didn't work, maybe someone of you can help me?
Thanks in advance







share|improve this question














closed as unclear what you're asking by muru, Ulrich Schwarz, Rui F Ribeiro, jasonwryan, Gilles Apr 11 at 6:57


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    It's kind of hard to offer concrete advice without seeing what awkLog does. Yes, maybe cut will be helpful, maybe rewrite to Perl or any other scripting language of choice.
    – Ulrich Schwarz
    Apr 11 at 6:48






  • 3




    Awk is still supported.
    – jasonwryan
    Apr 11 at 6:50






  • 2




    awk is still very much supported (as in "it's not deprecated"). If you need to replace awk with something else, you would have to investigate what the current script (awkLog) is doing and re-implement that in some other language or using some other parser. You mentioned "tags", does this mean that the current script is modifying XML? Without seeing what the awk script is doing, nobody can tell you what to replace it with.
    – Kusalananda
    Apr 11 at 6:54






  • 1




    Ok maybe to make things bit more clear I'm talking about the shell in an android phone. Maybe there it is no longer supported? Also the awkLog contains variables like $1, $2, ... and so on.
    – John
    Apr 11 at 7:00










  • Hi all I made the question a bit more clear as it was needed.
    – John
    Apr 11 at 7:32












up vote
-5
down vote

favorite









up vote
-5
down vote

favorite











I got some old shell scripts which use awk to replace some tags in a file called awkLog to make it more readable. The current command looks something like this:



awk log.txt -f awkLog > output.txt


The purpose is that the script is going to write data in log.txt like cpu usage and so on and after that it would "parse" the data and write it to output.txt in the order as specified in awkLog.



I looked for some replacements but unfortnaly I have no experience with shell scripting... I found that some are using the command cut. But I can't see how to implement this in the shell scripts.



The code of awkLog:



BEGIN maxfree = 0
minfree = 10000000000
savailable += $1
sused += $2
sfree += $3
sshared += $4
sbuff += $5
if ( $3 > maxfree ) maxfree = $3
if ( $3 < minfree ) minfree = $3
END print "MEMORY"
mavailable = savailable/NR
print "(average) available : ", mavailable
print "average used : ", sused/NR
print "average free : ", sfree/NR
print "average shared : ", sshared/NR
print "average buff : ", sbuff/NR
print "free max : ", maxfree
print "free min : ", minfree
print "Minimum MEMORY usage : ", mavailable-maxfree, "K"
print "Maximum MEMORY usage : ", mavailable-minfree, "K"
print "Average MEMORY usage : ", mavailable-sfree/NR, "K"


Inside the log.txt it looks like this:



User 1%, System 3%, IOW 0%, IRQ 0%
User 6 + Nice 0 + Sys 14 + Idle 420 + IOW 0 + IRQ 0 + SIRQ 0 = 440

PID PR CPU% S #THR VSS RSS PCY UID Name
10488 3 2% R 1 3704K 1248K fg shell top


Like I said I'm NO expert nor experienced user of shell scripting as I have ZERO experience with this so any help would be very much appreciated.



But it didn't work, maybe someone of you can help me?
Thanks in advance







share|improve this question














I got some old shell scripts which use awk to replace some tags in a file called awkLog to make it more readable. The current command looks something like this:



awk log.txt -f awkLog > output.txt


The purpose is that the script is going to write data in log.txt like cpu usage and so on and after that it would "parse" the data and write it to output.txt in the order as specified in awkLog.



I looked for some replacements but unfortnaly I have no experience with shell scripting... I found that some are using the command cut. But I can't see how to implement this in the shell scripts.



The code of awkLog:



BEGIN maxfree = 0
minfree = 10000000000
savailable += $1
sused += $2
sfree += $3
sshared += $4
sbuff += $5
if ( $3 > maxfree ) maxfree = $3
if ( $3 < minfree ) minfree = $3
END print "MEMORY"
mavailable = savailable/NR
print "(average) available : ", mavailable
print "average used : ", sused/NR
print "average free : ", sfree/NR
print "average shared : ", sshared/NR
print "average buff : ", sbuff/NR
print "free max : ", maxfree
print "free min : ", minfree
print "Minimum MEMORY usage : ", mavailable-maxfree, "K"
print "Maximum MEMORY usage : ", mavailable-minfree, "K"
print "Average MEMORY usage : ", mavailable-sfree/NR, "K"


Inside the log.txt it looks like this:



User 1%, System 3%, IOW 0%, IRQ 0%
User 6 + Nice 0 + Sys 14 + Idle 420 + IOW 0 + IRQ 0 + SIRQ 0 = 440

PID PR CPU% S #THR VSS RSS PCY UID Name
10488 3 2% R 1 3704K 1248K fg shell top


Like I said I'm NO expert nor experienced user of shell scripting as I have ZERO experience with this so any help would be very much appreciated.



But it didn't work, maybe someone of you can help me?
Thanks in advance









share|improve this question













share|improve this question




share|improve this question








edited Apr 11 at 7:32

























asked Apr 11 at 6:41









John

11




11




closed as unclear what you're asking by muru, Ulrich Schwarz, Rui F Ribeiro, jasonwryan, Gilles Apr 11 at 6:57


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by muru, Ulrich Schwarz, Rui F Ribeiro, jasonwryan, Gilles Apr 11 at 6:57


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    It's kind of hard to offer concrete advice without seeing what awkLog does. Yes, maybe cut will be helpful, maybe rewrite to Perl or any other scripting language of choice.
    – Ulrich Schwarz
    Apr 11 at 6:48






  • 3




    Awk is still supported.
    – jasonwryan
    Apr 11 at 6:50






  • 2




    awk is still very much supported (as in "it's not deprecated"). If you need to replace awk with something else, you would have to investigate what the current script (awkLog) is doing and re-implement that in some other language or using some other parser. You mentioned "tags", does this mean that the current script is modifying XML? Without seeing what the awk script is doing, nobody can tell you what to replace it with.
    – Kusalananda
    Apr 11 at 6:54






  • 1




    Ok maybe to make things bit more clear I'm talking about the shell in an android phone. Maybe there it is no longer supported? Also the awkLog contains variables like $1, $2, ... and so on.
    – John
    Apr 11 at 7:00










  • Hi all I made the question a bit more clear as it was needed.
    – John
    Apr 11 at 7:32












  • 1




    It's kind of hard to offer concrete advice without seeing what awkLog does. Yes, maybe cut will be helpful, maybe rewrite to Perl or any other scripting language of choice.
    – Ulrich Schwarz
    Apr 11 at 6:48






  • 3




    Awk is still supported.
    – jasonwryan
    Apr 11 at 6:50






  • 2




    awk is still very much supported (as in "it's not deprecated"). If you need to replace awk with something else, you would have to investigate what the current script (awkLog) is doing and re-implement that in some other language or using some other parser. You mentioned "tags", does this mean that the current script is modifying XML? Without seeing what the awk script is doing, nobody can tell you what to replace it with.
    – Kusalananda
    Apr 11 at 6:54






  • 1




    Ok maybe to make things bit more clear I'm talking about the shell in an android phone. Maybe there it is no longer supported? Also the awkLog contains variables like $1, $2, ... and so on.
    – John
    Apr 11 at 7:00










  • Hi all I made the question a bit more clear as it was needed.
    – John
    Apr 11 at 7:32







1




1




It's kind of hard to offer concrete advice without seeing what awkLog does. Yes, maybe cut will be helpful, maybe rewrite to Perl or any other scripting language of choice.
– Ulrich Schwarz
Apr 11 at 6:48




It's kind of hard to offer concrete advice without seeing what awkLog does. Yes, maybe cut will be helpful, maybe rewrite to Perl or any other scripting language of choice.
– Ulrich Schwarz
Apr 11 at 6:48




3




3




Awk is still supported.
– jasonwryan
Apr 11 at 6:50




Awk is still supported.
– jasonwryan
Apr 11 at 6:50




2




2




awk is still very much supported (as in "it's not deprecated"). If you need to replace awk with something else, you would have to investigate what the current script (awkLog) is doing and re-implement that in some other language or using some other parser. You mentioned "tags", does this mean that the current script is modifying XML? Without seeing what the awk script is doing, nobody can tell you what to replace it with.
– Kusalananda
Apr 11 at 6:54




awk is still very much supported (as in "it's not deprecated"). If you need to replace awk with something else, you would have to investigate what the current script (awkLog) is doing and re-implement that in some other language or using some other parser. You mentioned "tags", does this mean that the current script is modifying XML? Without seeing what the awk script is doing, nobody can tell you what to replace it with.
– Kusalananda
Apr 11 at 6:54




1




1




Ok maybe to make things bit more clear I'm talking about the shell in an android phone. Maybe there it is no longer supported? Also the awkLog contains variables like $1, $2, ... and so on.
– John
Apr 11 at 7:00




Ok maybe to make things bit more clear I'm talking about the shell in an android phone. Maybe there it is no longer supported? Also the awkLog contains variables like $1, $2, ... and so on.
– John
Apr 11 at 7:00












Hi all I made the question a bit more clear as it was needed.
– John
Apr 11 at 7:32




Hi all I made the question a bit more clear as it was needed.
– John
Apr 11 at 7:32










1 Answer
1






active

oldest

votes

















up vote
2
down vote













what I understood from your question is that you would like to replace a string in a file. if it so, sed is the better command.



sed -i 's/oldString/newString/g' log.txt






share|improve this answer
















  • 1




    The word "tag" implies XML (possibly), in which case the proper "replacement for awk" would be a an XML parser.
    – Kusalananda
    Apr 11 at 6:52










  • @siva m thanks I'll give it a try.
    – John
    Apr 11 at 7:23

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













what I understood from your question is that you would like to replace a string in a file. if it so, sed is the better command.



sed -i 's/oldString/newString/g' log.txt






share|improve this answer
















  • 1




    The word "tag" implies XML (possibly), in which case the proper "replacement for awk" would be a an XML parser.
    – Kusalananda
    Apr 11 at 6:52










  • @siva m thanks I'll give it a try.
    – John
    Apr 11 at 7:23














up vote
2
down vote













what I understood from your question is that you would like to replace a string in a file. if it so, sed is the better command.



sed -i 's/oldString/newString/g' log.txt






share|improve this answer
















  • 1




    The word "tag" implies XML (possibly), in which case the proper "replacement for awk" would be a an XML parser.
    – Kusalananda
    Apr 11 at 6:52










  • @siva m thanks I'll give it a try.
    – John
    Apr 11 at 7:23












up vote
2
down vote










up vote
2
down vote









what I understood from your question is that you would like to replace a string in a file. if it so, sed is the better command.



sed -i 's/oldString/newString/g' log.txt






share|improve this answer












what I understood from your question is that you would like to replace a string in a file. if it so, sed is the better command.



sed -i 's/oldString/newString/g' log.txt







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 11 at 6:49









SivaPrasath

5,39222950




5,39222950







  • 1




    The word "tag" implies XML (possibly), in which case the proper "replacement for awk" would be a an XML parser.
    – Kusalananda
    Apr 11 at 6:52










  • @siva m thanks I'll give it a try.
    – John
    Apr 11 at 7:23












  • 1




    The word "tag" implies XML (possibly), in which case the proper "replacement for awk" would be a an XML parser.
    – Kusalananda
    Apr 11 at 6:52










  • @siva m thanks I'll give it a try.
    – John
    Apr 11 at 7:23







1




1




The word "tag" implies XML (possibly), in which case the proper "replacement for awk" would be a an XML parser.
– Kusalananda
Apr 11 at 6:52




The word "tag" implies XML (possibly), in which case the proper "replacement for awk" would be a an XML parser.
– Kusalananda
Apr 11 at 6:52












@siva m thanks I'll give it a try.
– John
Apr 11 at 7:23




@siva m thanks I'll give it a try.
– John
Apr 11 at 7:23


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay