bash's questions - Chinese 1answer

14.008 bash questions.

Fixing my PATH variable

2 answers, 1.644 views bash path
I am perplexed by the following problem and hoping someone can help me fix it: when I type echo $PATH, I get the output: /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games However, I modified ...

I an using Ubuntu 14.04. I have a script that is supposed to run at all times. The easy way would be to use crontab to run another script that checks if script1 is running and if not restart it. I ...

According to the bash man page: The redirection operator [n]<&digit- moves the file descriptor digit to file descriptor n, or the standard input (file descriptor 0) if n is ...

My question is related to https://serverfault.com/questions/171095/how-do-i-join-two-named-pipes-into-single-input-stream-in-linux but with a slightly more convoluted setup. I have three programs, ...

I want to run a program in an empty environment (i.e. with no envariables set). How to do this in bash?

Here is a snippet from my .bash_profile: alias hi=“echo hi” alias oe=“open -e” alias u=“cd ..” alias uu="cd ../../“ alias uuu=“cd ../../../“ If I attempt to run a command using ...

I have a following script scheduled to run every 5 minute that checks for two services and if it found any service status down,it sends email. Its working ok. But the issue is I want it to send UP ...

I have a django project. I can list all of its python files with ls **/**/**.py How can I omit files that are in migrations folders?

I'm using putty client in windows to connect to remote Debian 6 via SSH. If I login as root I have normal command prompt like root@ion:~# and command autocomplete works fine when press tab. In case I ...

I'm trying to fetch remote machine details (dmidecode) for many hosts using some expect command. Below is the expect script which I'm using for this purpose. while read i; do { /usr/bin/expect<&...

I have following text in a text file $ cat test 20180618: 20180619: 20180620: 20180621: 20180622: 20180623: 20180624: I have tried to grep with the range of numbers like below, $ grep 201806{19..21}...

Can anyone point me to a bash tab autocomplete for the java keytool command? Learning & writing this seems not simple, and I presume that someone has felt this pain before.

On ubuntu 15.04, I am running java app through vnc sessions. I have 8 defined sessions that are started during system boot. My question is, how do I create a script that checks to see if the process ...

I'm using Arch with i3wm. I start my session with xinit, and in my i3 config I execute the following script: #!/bin/bash setxkbmap -option '' setxkbmap -model abnt2 -layout us,br -variant mac,abnt2 ...

I'm trying to push code using git to my remote server, but I get the error: fatal: protocol error: bad line length character: 8 I researched this bug and it turns out my .bashrc file that echos ...

I am looking for a shell script that would flatten a given directory structure but ONLY if there is only 1 subfolder in that directory. For instance: the script would flatten this folder: /folder ...

Hi I'm really new to writing scripts and I searched a lot but all that I've found is scripts with full access. I don't have access to the /etc. I'm working in a host in the cloud but I have limited ...

I'd like to do this on bash apt install -y \ curl \ # i'd like to insert comment here somehow python3 But this doesn't work.

I've been trying to do some bufferoverflow attack, and I tought I could use system("/bin/bash") in order to obtain a root shell. Then I read the documentation for system(). It says : system() ...

Say I have npmv="3.4.5"; what is the simplest way to get all the characters before the first dot? In this case that would be "3"?

I have a situation where I'm trying to install software into my system. I'm using a fakeroot approach to install them in a separate directory where I'm listing all the files, directories and links ...

When I log in with the same user on tty1 and tty2 and start an X server session on tty1 - as soon as I log out of tty2, the X server session on tty1 crashes. This seems to be a known bug: https://...

I've been Googling and searching StackExchange to find how to call different scripts in bash file with parameters. For example, I would write ./configure --enable-mpi or some other command on the ...

I have some php packages installed globally using php composer within a script sudo -u me composer global require "phpmd/phpmd" I want to find the path of these globally installed php packages. When ...

When I open a shell in ranger with shift-s, open vim and then open a shell with :sh or open a new shell tab with ctrl-shift-t, my xmodmap keybindings (swapped caps lock and escape keys) are reset. ...

For example, I want to check if a directory exists on the phone. R=$(adb shell 'ls /mnt/; echo $?' | tail -1); $ echo $R 0 $ if [ "$R" -ne 0 ]; then echo "Path doesn't exist"; else echo "Path ...

I have many pairs of integers like (a,b),(c,d),(e,f) .. so on. I need to check if the value of 1st element lies between a range of 90% to 150% of the 2nd element and print the value as Pass. The ...

I'm trying in a heredoc to set its output to a local variable as follows : REMOTE_OUTPUT=$(ssh remote@server /bin/bash << EOF find my/path/ -type f -not -path my/path/*/ -type f -mtime -0 | ...

I have this cronjob: #!/bin/bash YEAR=`date +%Y` MONTH=`date +%m` DAY=`date +%d` mkdir -p $YEAR/$MONTH/$DAY mysqldump -uroot -p1234 locatari > $YEAR/$MONTH/$DAY/backup.sql And I want to run this ...

I have a very simple .sh script to kill a process. The processes saves its PID to pid2.txt. pkill -e -P $(cat pid2.txt) exit When I run this as sudo ./myscript.sh from the command line it works fine....

Either I've completely misunderstood something about symlinks (most likely), or their behaviour has changed at some point and I'm now catching up. I have a script directory that resides somewhere on ...

I am at a bit of a loss as to the purpose of set and export in Bash (and I guess probably other shells too). I would think it is for setting environment variables, but that can be done just with ...

I have a text file like the one below although with almost many columns. I want to extract column names that have a specific proportion/number of TRUE values, for example columns with TRUE in 2 out of ...

I am looking to get tab-completion on my command line aliases, for example, say I defined the following alias : alias apt-inst='sudo aptitude install' Is there a way to get the completions provided ...

My usecase is a yad program that uses another script that mounts a filesystem. What i'm currently doing and somewhat unsatisfied by is a complex dance of kill and wait to 'simulate' having the return ...

Today I noticed that my bash history is cleared completely. I have neither executed history -c nor deleted the .bash_history file. Apart from deleting the .bash_history file and history -c, how can ...

Is this right way of doing float to integer in bash, Or is there any other method ? flotToint() { printf "%.0f\n" "$@" }

Please review these codes that are aimed to do basically the same task (finding the main .htaccess of the site and changing it): for dir in "$HOME"/public_html/*.{com,co.il}/; do if pushd "$dir"; ...

In the bash reference manual it states: lithist If enabled, and the cmdhist option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon ...

This is similar to How can I generate a full listing of the files installed by a package? However, I haven't installed the package, yet. I wanted to list all files which will be installed by APT ...

Suppose I have entered a function at the bash prompt, on multiple lines rather than squeezing it onto one with semicolons: $ function blah { echo blah } $ history -1 12690 function blah {\necho ...

I have to write a Bash script which checks if another Bash script contains a certain command line. Since Bash allows you to split a command line over multiple lines, my script must be able to merge ...

Over many years I used ksh. I like the possibility to use Esc v in command history to call the editor "vi". If this command in the history was spread over many lines - for example because of a while ...

I need to create a deploy script to combine the following directory structure: ├── LIB_COMMON │ ├── file1.php │ ├── file2.php │ ├── file3.php │ └── file4.php ├── LIB_CZ │ ├── file2.php │ ...

I am not sure if I understood this lines correctly: # set environment variables (if not already done) export PYTHON_ROOT=~/Python export PYSPARK_PYTHON=${PYTHON_ROOT}/bin/python export PATH=${...

I have a function (=callee) that should effectively declare and assign a couple of variables in its caller. It should also be able to tell what it's caller's name is. For now I achieve the former by ...

Is it possible to format this sample: for i in string1 string2 stringN do echo $i done to something similar to this: for i in string1 string2 stringN do echo $i done EDIT: Sorry for confusion, ...

I sometimes have quite a big range of tabs open in Firefox and I prefer it to save them to a file, rather then using the build-in bookmarks. Therefore I (manually) copy the urls from the about:...

it seems my bash-completion got corrupted. Every time I try to use command substitution, for example when I type ls $(ls Deskto<Tab> ..result is.. ls $(ls Desktobash unexpected eof while ...

First of all, I am new to scripting and I am still learning. So please forgive me for any blunders here. I am running Ubuntu 18.04. I have a directory full of storyboard images in .jpg format as ...

Related tags

Hot questions

Language

Popular Tags