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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:13:49+00:00 2026-05-29T12:13:49+00:00

So I have this block of code. Basically, I’m taking file $i, checking if

  • 0

So I have this block of code. Basically, I’m taking file $i, checking if it’s got content or not, checking if I can read it, if I can open it, grab the first line and see if it’s a bash file. When I run this every time on a non-empty file, it was registers as true and echo’s bash.

            ## File is empty or not
            if [[ -s $i ]]
            then
                ## Can we read the file 
                if [[ -r $i ]]
                then
                    ## File has content
                    if [[ $(head -n 1 $i) = "#! /bin/bash" ]]
                    then
                        echo -n " bash"
                    fi
                fi
            else
                ## file does not have content
                echo -n " empty"
            fi

This is what does the check of if it’s bash:

if [[ $(head -n 1 $i) = "#! /bin/bash" ]]
  • 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-29T12:13:51+00:00Added an answer on May 29, 2026 at 12:13 pm

    Replace [[ with [ and enclose $(head -n 1 $i) in quotes.

    [[ is itself an operator that tests its contents.

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

Sidebar

Related Questions

Any way I can get this working? I have a block of code: <p><a
I have this block of code: users = Array.new users << User.find(:all, :conditions =>
If I have a block of code like this: def show @post = Post.find(params[:id])
Let's say I have cleaner like this .cleaner:after { content: '.'; display: block; clear:
I have a block of code that basically intializes several classes, but they are
I have a code something below: function showHideOptions() { $(#template1, #template2, #template3, #template4).css(display,none); $(this).css(display,block);
I have this block of code executed when pressing a number: NSString *currentValue =
I have code that basically looks like this (it isn't actually object, but rather
i have this block of xslt if-else case and was wondering if there's a
I have this block of xaml that allows the text of a hyperlink 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.