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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:08:09+00:00 2026-06-09T17:08:09+00:00

The file under test will have text patterns like this: name1: function(){ }, name2:

  • 0

The file under test will have text patterns like this:

name1: function(){

},
 name2: function(){

},
 name3: function(){

}, 

I need to get “name1” “name2” and “name3” in this example.
So used this bash script:

v1='},'
v2=': function'
sed 's/'"$v1"'\(.*\)'"$v2"'/\1/g' test1.js > newfile2

This seems to work only if the pattern shows up like:

 },name1: function 

But of course the text file is not formatted this way. it’s like this:

 },
name1: function

What should I add to the regex that would accomplish what i need?
I do not want to change from using sed

Thanks

  • 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-09T17:08:11+00:00Added an answer on June 9, 2026 at 5:08 pm
    sed -n 's/\s*\([^: ]*\): function.*/\1/p' test1.js
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Supposed I have a test.lua file like this: myVar = 5 Food = function()
I have a duplicated configuration file under WEB-INF directory, called configDEV.properties and configPRO.properties (one
Inside a grails application, I need to upload a file under web-app/js, add a
I'm confused with file moving under python. Under windows commandline, if i have directory
Is there a way to have the file reference work under ipad? The file
Under Windows 7 I have a batch file for checking the status of some
Given some source file test.cpp I would like to create a shared library libtest.so
I have an application where I need to open an xml file, modify it,
I need to create vbscript which will create new folder 'test' and subfolder 'Output'.There
I have one very large text file(27GB) that I am attempting to make smaller

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.