Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:28:40+00:00 2026-06-08T17:28:40+00:00

So, currently i have created a code to do this as shown below. This

  • 0

So, currently i have created a code to do this as shown below. This code works and does what it is supposed to do after I echo the variables:

a=`awk 'NR==2 {print $1}' $coor`

b=`awk 'NR==3 {print $2}' $coor`

c=`awK 'NR==4 {print $3}' $coor`

….but i have to do this for many more lines and i want a more general expression. So I have attempted to create a loop shown below. Syntax wise i don’t think anything is wrong with the code, but it is not outputting anything to the file “Cmain”.

I was wondering if anyone could help me, I’m kinda new at scripting.

If it helps any, I can also post what i am trying to read.

for (( i=1; i <= 4 ; i++ )); do
  for (( j=0; j <= 3 ; j++ )); do
    B="`grep -n "cell" "$coor" | awk 'NR=="$i" {print $j}'`"
  done
done

echo "$B" >> Cmain
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:28:42+00:00Added an answer on June 8, 2026 at 5:28 pm

    You can replace your lines of awk with this one:

    awk '{ for (i=1; i<=NF; i++) if (NR >= 2 && NR == i) print $(i - 1) }' file.txt
    

    Tested input:

    1 2 3 4 5 6 7 8 9 10
    11 12 13 14 15 16 17 18 19 20
    21 22 23 24 25 26 27 28 29 30
    31 32 33 34 35 36 37 38 39 40
    41 42 43 44 45 46 47 48 49 50
    51 52 53 54 55 56 57 58 59 60
    61 62 63 64 65 66 67 68 69 70
    71 72 73 74 75 76 77 78 79 80
    

    Output:

    11
    22
    33
    44
    55
    66
    77
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
I currently have a thread that I created using CreateRemoteThread(). Everything works great. Upon
I have the code below (this is actually part of a much more complicated
Currently I have created a ABCFactory class that has a single method creating ABC
I currently have a (non commercial) application created in MS Visual C# 4.5, using
We currently have a tool on our website that is created by JavaScript. The
I have created an Eclipse plugin which creates a view in Eclipse. Currently it
I am currently trying to pass an array that I have created in Javascript
I am currently working on grails project. I have created eight different plugins. Each
I'm currently developing a module for Drupal 6, in which I have created a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.