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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:56:51+00:00 2026-06-12T15:56:51+00:00

Using an array of line numbers acquired through a grep command, I’m trying to

  • 0

Using an array of line numbers acquired through a grep command, I’m trying to then increase the line number and retrieve what is on the new line number with a sed command, but I’m assuming something is wrong with my syntax (specifically the sed part because everything else works.)

The script reads:

#!/bin/bash


#getting array of initial line numbers    

temp=(`egrep -o -n '\<a class\=\"feed\-video\-title title yt\-uix\-contextlink  yt\-uix\-sessionlink  secondary"' index.html |cut -f1 -d:`)

new=( )

#looping through array, increasing the line number, and attempting to add the
#sed result to a new array

for x in ${temp[@]}; do

((x=x+5))

z=sed '"${x}"q;d' index.html

new=( ${new[@]} $z ) 

done

#comparing the two arrays

echo ${temp[@]}
echo ${new[@]}
  • 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-12T15:56:52+00:00Added an answer on June 12, 2026 at 3:56 pm

    You’re sed line should probably be:

    z=$(sed - n "${x} { p; q }"  index.html) 
    

    Notice that we use the “-n” flag to tell sed to only print the lines we tell it to. When we reach the line number stored in the “x” variable, it will print it (“p”) and then quit (“q”). To allow the x variable to be expanded, the commabd we send to sed must be placed between double quotes, and not single quotes.

    And you should probably place the z variable between double quotes when using it afterwards.

    Hope this helps =)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this line of code to insert a value from an array into
I have a textarea that contains phone numbers, each number in a separate line.
I need to call a program from cmd using an array of numbers(mandatory) and
I have to make an array of 100 numbers and then shuffle the first
I'm trying to create a simple average calculator using an array with randomly generated
I am trying to read a file into a global array, loop through the
I am using Array() with each_with_index to output a array with index but I
I'm currently using Array.Copy to shift an array as such: Array.Copy(array, 0, array, 1,
I'm using Array.sample to return a random element from an array. I want to
I need to create an array of arrays. I have been using array_map(null,$a,$b,$c) to

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.