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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:28:15+00:00 2026-05-13T21:28:15+00:00

I want to write a very simple script , which takes a process name

  • 0

I want to write a very simple script , which takes a process name , and return the tail of the last file name which contains the process name.

I wrote something like that :

#!/bin/sh
tail $(ls -t *"$1"*| head -1) -f

My question:

  1. Do I need the first line?

  2. Why isn’t ls -t *"$1"*| head -1 | tail -f working?

  3. Is there a better way to do it?

  • 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-13T21:28:15+00:00Added an answer on May 13, 2026 at 9:28 pm

    1: The first line is a so called she-bang, read the description here:

    In computing, a shebang (also called a
    hashbang, hashpling, pound bang, or
    crunchbang) refers to the characters
    “#!” when they are the first two
    characters in an interpreter directive
    as the first line of a text file. In a
    Unix-like operating system, the
    program loader takes the presence of
    these two characters as an indication
    that the file is a script, and tries
    to execute that script using the
    interpreter specified by the rest of
    the first line in the file

    2: tail can’t take the filename from the stdin: It can either take the text on the stdin or a file as parameter. See the man page for this.

    3: No better solution comes to my mind: Pay attention to filenames containing spaces: This does not work with your current solution, you need to add quotes around the $() block.

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

Sidebar

Related Questions

I wrote a very simple perl script, and now I want to make it
I'm trying to write a very simple program, I want to print out the
I'm attempting to write a very basic script using javascript. What I want to
I want write a simple query which will fetch data from a table (which
I wanted to write a very simple greasemonkey script because I hate the are
Hi all I'm using Google Sites and I want to write a very simple
I'm trying to write a very simple email script in python. It's basically a
I am trying to write a very simple script that would simulate a pocket
I want to do something very simple in javascript. I have a main.js file
This is a very simple bash script I wrote: #!/bin/bash ITEM_LIST=items.txt LOG_FILE=log.log TOTAL_ITEMS=$(wc -l

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.