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 4346472
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:10:39+00:00 2026-05-21T12:10:39+00:00

for (( int i=$4; i<$5; i++ )) do awk NR==i{print} $1 done I want

  • 0
for (( int i="$4"; i<"$5"; i++ ))
do
     awk "NR==i{print}" $1
done

I want awk to print out the records between $4 and $5 ( itll be a range, ie 4-9 )

cant figure out why im getting this error?

Syntax error in expression ( error token is "i=2" )
  • 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-05-21T12:10:40+00:00Added an answer on May 21, 2026 at 12:10 pm

    awk doesn’t know anything about the shell variable i, for a start, Why would you just not use:

    awk "(NR >= $4) && (NR <= $5) {print}" $1
    

    The shell itself should expand the $ variables since they’re within double quotes rather than single quotes (this is shell-dependent of course but covers the most popular ones, primarly bash).

    You can see this in action in the following transcript:

    ====
    pax$ cat infile
    ..1
    ..2
    ..3
    ..4
    ..5
    ..6
    ..7
    ..8
    ..9
    
    ====
    pax$ cat qq.sh
    #!/usr/bin/bash
    
    awk "(NR >= $4) && (NR <= $5) {print}" $1
    
    ====
    pax$ ./qq.sh infile junk junk 2 5
    ..2
    ..3
    ..4
    ..5
    
    ====
    pax$ _
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The author claims that his awk script will print out all the limits for
int x = n / 3; // <-- make this faster // for instance
int somefunction(bool a) { try { if(a) throw Error(msg); return 2; } catch (Error
I have a file with function prototypes like this: int func1(type1 arg, int x);
int m=32 printf(%x , ~m); Output of this statement is ffdf and without ~
I'm a Physicist and, usually, I just want to get the calculations done and
int i =132; byte b =(byte)i; System.out.println(b); Mindboggling. Why is the output -124 ?
i couldn't solve this. when i execute this program i get the following error
I have a bash sequence, grep integer = $1 | awk -F= '{printf(%d\n,int($2*327))}' which
I'm looking for a method to cast a string to an int in awk.

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.