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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:48:25+00:00 2026-06-07T20:48:25+00:00

In a script (Say myScript.ksh) I have a variable which contains path to a

  • 0

In a script (Say myScript.ksh) I have a variable which contains path to a file.

file=/home/vikas/input.ksh

in my code a need something from that file so I am doing a normal cat and grep on this file by doing something like this

myVariable=`cat $file | grep "on this line" | cut -d"'" -f2`

Now everytime I launch myScript.ksh, I get a error

cat: cannot open /home/vikas/input.ksh

But if I do same thing direcly on terminal I am able to see content of the file input.ksh

I dont know what I am doing wrong, can somebody please help me ?

  • 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-07T20:48:29+00:00Added an answer on June 7, 2026 at 8:48 pm

    yeah finally the problem solved, though I found the solution weired and could not understand why it worked. Actually I was reading this variable from some other file and it was something like this

    file=$HOME/vikas/input.ksh 
    

    the problem was with $HOME what I did I removed $HOME from variable file and added that again by doing this

    file=`echo $file | awk 'BEGIN { FS="/"; OFS="/" } {$1=""; print $0}'`
    
    file=$HOME$file 
    

    and after that I did the cat $file and it worked

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

Sidebar

Related Questions

Say I have a file at the URL http://mywebsite.example/myscript.txt that contains a script: #!/bin/bash
I have a vb script (say myScript.vbs) which is used to monitor a file
Say I have MyScript.ps1 : [cmdletbinding()] param ( [Parameter(Mandatory=$true)] [string] $MyInput ) function Show-Input
Let's say I'm writing a bash script myscript.bash, which expects a single argument ($1).
Let's say I have the following script. This script finds the largest file under
I have a simple python script (say, simple.py) , like a = 5 b
In a shell script lets say i have run a command like this for
Lets say I have the following script k <- as.numeric(readline(Start Index: )) tot <-
Say I have a script written in perl or python. What's the easiest way
Say I have a SSI script that uses exec, or a PHP script that

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.