Unix/Linux Go Back    


Fedora is an operating system centered on the Linux open source kernel and is developed by the community-supported Fedora Project. Fedora is sponsored by Red Hat. Fedora contains software distributed under a free and open-source license. Fedora focuses on innovation, integrating and adopting new technologies and working closely with various Linux communities. The default desktop in Fedora is the GNOME desktop environment and the default user interface is the GNOME Shell. Other desktop environments include KDE Plasma, Xfce, LXDE, MATE and Cinnamon. Security is an important aspect of Fedora with one specific security feature, Security-Enhanced Linux, implementing a variety of software security policies, including mandatory access controls.

Shell Script - awk, begin, for and print

Fedora


Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 08-31-2013
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 January 2017, 4:51 AM EST
Location: Aachen, Germany
Posts: 10,143
Thanks: 229
Thanked 3,067 Times in 2,844 Posts
You could use shell arithmetics, but this is quite limited on some shells. On others, yes, you can.
Sponsored Links
    #9  
Old Unix and Linux 08-31-2013
agriz agriz is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 1 September 2013, 12:30 AM EDT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
I understood that pointsb will hold the values of awk's execution


Code:
pointsb = 'final result of awk'

What does that awk do?

It does some looping and prints x,y values. I assume it will be stored in pointsb.
so pointsb might be holding something like this.

pointsb = 1,2 4,5 2,3 5,6
is that right?

Or what does awk return to pointsb?
I am not able to guess this. How does the variable assign work here?
Sponsored Links
    #10  
Old Unix and Linux 08-31-2013
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 January 2017, 4:51 AM EST
Location: Aachen, Germany
Posts: 10,143
Thanks: 229
Thanked 3,067 Times in 2,844 Posts
Read your shell's man page on command substitution.
Read the awk man page. It's a very powerful pattern scanning and text processing language.
    #11  
Old Unix and Linux 09-01-2013
agriz agriz is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 1 September 2013, 12:30 AM EDT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by RudiC View Post
Read your shell's man page on command substitution.
Read the awk man page. It's a very powerful pattern scanning and text processing language.
Your replies saved lot of time in learning shell script and made life easier Linux

* I downloaded Fedora 19
* I installed it in my laptop
* I created that simple shell script and executed to know the pointsb value with some dummy values of other variables
* I created another shell script without awk


Code:
pointsb = ""
for (y=yc; y<=yb; y++) { 
    x = a2*y*y+b2*y+c2; 
    pointsb = "$pointsb $x $y "
}

The logic is completely right in the above code apart from the system mistakes. I am sure i am not going to write any shell script. I just wanted to learn it. So when i read a script, i could understand the flow.

Have a good day!
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to print backslash in shell script using awk? wxuyec Shell Programming and Scripting 8 01-30-2013 04:37 PM
strange: sed and awk print at end instead of begin of line regisl67 Shell Programming and Scripting 5 10-18-2011 01:10 PM
awk/shell script to print each line to a file saint2006 Shell Programming and Scripting 3 01-06-2010 11:26 AM
shell script(Preferably awk or sed) to print selected number of columns from each row ks_reddy Shell Programming and Scripting 3 08-25-2009 08:39 AM
awk getting stuck after BEGIN akshaykr2 Shell Programming and Scripting 1 06-24-2009 02:04 PM



All times are GMT -4. The time now is 05:52 AM.