Skip to content
Advertisement

Tag: bash

Get the name of the directory where a script is executed

I have some script, that uses files in directories around it. It uses command. It should work from any directory where I run this script, but when I run a symbolic link that points to that script I get the path of symbolic link. So I get the output of dirname rather than the path of the script itself. Any

BASH: how to perform arithmetic on numbers in a pipe

I am getting a stream of numbers in a pipe, and would like to perform some operations before passing them on to the next section, but I’m a little lost about how I would go about it without breaking the pipe. for example Would you have any ideas on how to make something like this work? The actual operation I

Convert .cshrc to .bashrc [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago. Improve this question I am new to Linux and I am trying to compile some code that needs environment variables set first. The script is in cshrc, but

Parsing result of Diff in Shell Script

I want to compare two files and see if they are the same or not in my shell script, my way is: Basically, if they are the same ${diff_output} should contain nothing and the above test would evaluate to true. But when I run my script, it says [: too many arguments On the if [….] line. Any ideas? Answer

Prevent * to be expanded in the bash script

Linux bash script: Execution results: * is expanded to the list of files, which is actually script itself. How can I prevent this and see actual variable value? In general case, var can be more complicated than *, for example: home/alex/mydir/*. Answer you need to escape your variables, too: And in your function:

Surprise! the shell suggests command line switches

I noticed that the bash shell can suggest command line switches for your command. Just type your command, a dash (-) and type tab. The shell will show you available switches. For example, try: and press tab – Surprise! The question is: How do I interface with this feature. I.e., if I write a program that is to be run

Advertisement