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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:17:28+00:00 2026-05-26T05:17:28+00:00

given the name of a file as an argument,the script reads the file name

  • 0

given the name of a file as an argument,the script reads the file name and creates a new file containing only lines which consist of one word.

An example input and output will be

There
are 20 students in the class.
[TAB][SPACE] Nearly
half of them are enrolled in FoS. The rest are in
Faculty-Of-ES.

The output from the script should look like

There
[TAB][SPACE] Nearly
Faculty-Of-ES.

Hello I am a beginner programmer and I am trying to learn bash scripting for over a month now but questions like this still stump me.
Please outline the general approach .Thank you

  • 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-26T05:17:29+00:00Added an answer on May 26, 2026 at 5:17 am

    grep -P "^[\s]*[0-9A-Za-z-]+.?[\s]*$" test.txt

    Where test.txt contains the input text.

    Here I am defining a word as having zero or more whitespace in the beginning and end . Then any combination of alphabets, digits and - and optionally ending with a period.

    NOTE :: This will not work if you are considering floating point numbers as a word. Hence your definition of a word defines the result and the regex.

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

Sidebar

Related Questions

I'm writing a batch file on Windows which gets one argument: a zip file
I have to search a given file name (let say Keyword) in a directory
Given the name of a file, how can I determine if the file is
Given a string location and string file name, is it possible to execute a
Given this example XML file: <doc> <tag> Hello ! </tag> <tag> My name is
I want to make a script that takes a file path for argument, and
I'm writing a bash script that will (hopefully) redirect to a file whose name
From the registry, for a given file type, I get a string containing something
I want to give the name of MainWindow.xib file in plist file through code,
I want to delete all files in a directory with a given name, except

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.