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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:28:01+00:00 2026-05-27T10:28:01+00:00

i have in a linux directory a lot of files, plain text with some

  • 0

i have in a linux directory a lot of files, plain text with some directories, and i want to search in all those files and get the exactly the string between “-(” and “)-” like:

bbbfb da bg -(fdsd)- fgfjmui -( juju gfdgf b)- fsdf sdfs dsfdlk,kwwk
xwpv -(64fsdfds)- fsdfsd -(a)- fsdfsd…

and return:

  • fdsd
  • juju gfdgf b
  • 64fsdfds
  • a
    …

i read for a while, and i found commands like grep, but i tried and i think that command return the exactly string and just one by line:

grep -Rn "-(" *

i tried also sed command like:

sed -e 's/.*-(\([^"]*\))-.*/\1/'

which return all the lines and where is the pattern, only the string inside -( and )-, but is not quite right yet.

i read about awk, but my question is: is possible with grep, sed or awk? there some more things to put on sed command? (i’m kinda new on this)
there is another command to do this? or the other idea i was thinking is make a little c program to read files char by char

  • 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-27T10:28:02+00:00Added an answer on May 27, 2026 at 10:28 am
    grep -RPo '(?<=-\()[^)]*(?=\)-)' yourDir
    

    this will give you the strings you want each per line

    test with your example:

    kent$  echo "bbbfb da bg -(fdsd)- fgfjmui -( juju gfdgf b)- fsdf sdfs dsfdlk,kwwk xwpv -(64fsdfds)- fsdfsd -(a)- fsdfsd..."|grep -Po '(?<=-\()[^)]*(?=\)-)'
    fdsd
     juju gfdgf b
    64fsdfds
    a
    

    the trick here is “o”: from man page of grep:

    -o, –only-matching
    Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.

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

Sidebar

Related Questions

I'm on linux, and I have a directory with numerous sub-directories and items inside
All, I have installed xampp for linux on ubuntu 9.10. The installation directory is
lets say I have (linux/unix) /directory/1/file.wmv /directory/2/file.wmv /directory/3/file.wmv I want to copy these .wmv
I have some Linux code that monitors our hardware by collecting temperatures, voltages, and
I have a Linux box and I want to be able to telnet into
Hi I have 2 questions regarding linux directory permissions which I do not understand.
Inside of my Linux directory, I have a file named TopSample$Config.class . Whenever I
I have a directory with a bunch of .sql files that mysql dumps of
I have a pretty large directory /var/www/ on my linux Ubuntu server. In that
I have a doubt. I opened the kernel and I changed the directory linux-3.1.1/fs/open.c

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.