Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

0
votes
0answers
6 views

Bash scripts ran from from gnome/nautilus don't have enviroment variables

In my ~/.bashrc and ~/.profile I have some variables set to some filepaths: export MY_VAR1="/path/to/somewhere" In my ~/bin/ (which is added to my PATH) I have a few scripts that rely on those ...
1
vote
1answer
3 views

Virtualbox list vrde port for vm on commandline

I have a Virtualbox VM that is configured with VRDE for remote access using RDP. I'm familiar with how to set the vrde port, but for a given VM I have not found a way to query the current vrde port ...
1
vote
3answers
43 views

How to test for unknown commands in shell script?

I would like to know, if there is a way to go through a shell script and getting a warning for every command, that is unknown. I know bash -n for syntax checking, but it doesn't tell me, if there are ...
0
votes
1answer
17 views

Confusion about basic bashscript loop - until/done

I have a bash script I'm working on to help with an installer. why doesn't this work? function fn_myFunc(){ local MYVAR=0 until ["$MYVAR" -ne 0]; do whiptail --yesno ...
7
votes
2answers
159 views

Start a process on a different tty

After about an hour of Googling this, I can't believe nobody has actually asked this question before... So I've got a script running on TTY1. How do I make that script launch some arbitrary program ...
0
votes
0answers
3 views

Capturing data from a Fluke 1620a via Bash /dev/tcp file descriptor

I am currently trying to develop a script that will connect to a Fluke DewK 1620a Themo-Hygrometer and pull the current temperature and humidity readings from the device. While these devices have a ...
4
votes
3answers
209 views

in Bash, how to not include extra arguments in an alias?

I am trying to do something like alias ftp='echo do not use ftp. Use sftp instead.' just so that ftp will not be accidentally used. But I noticed that ftp abcd.com will cause the command to ...
-2
votes
0answers
31 views

making a delete script and a restore script

I'm looking to create two scripts; one to "delete" a script, and one to "restore" I need "del " where this will move the file located at to the dustbin directory in a way that will allow it to be ...
-1
votes
1answer
19 views

how to replace a specific pattern from all files [duplicate]

suppose I want to replace abc with xyz in all files in a directory. How do I write a script for this ?
1
vote
0answers
37 views

Update process name in shell, is it possible?

In C/C++ it is in general possible to do strcpy(argv[0], "new process name"). It's a hack used in malicous software to hide real process name. Is such operation possible via shell? What I want to do ...
2
votes
0answers
23 views

Programmatically get CPUs 'detailed' usage, like top/htop

htop has a great way to show CPU usage. It shows the activity (usage in %) of each cores, and each core gauge is divided into three parts : blue: low priority processes green: normal processes red: ...
3
votes
2answers
75 views

Using `case` to handle script arguments

Can I use the case statement to handle arguments? So, using -restart I'd like execute "-umount" and "-mount" #!/bin/bash case "$1" in -mount mount /ip/share1 /local/share1 ;; -umount umount ...
4
votes
7answers
527 views

Remove everything that is not a 4 character number

I need to remove everything that is not a 4 character number such as 9838, 6738, 1337 or 1889. I though that this command would work: sed 's/....[^0-9]//g' . Means any character in regex, and ...
0
votes
1answer
20 views

check status process output

I wanted to understand how to create a script sh that allows me to see if an additional script functions correctly. For now this is the script that I created. if /run.sh status echo "$SERVICEXE ...
1
vote
1answer
40 views

Difference between / and // [duplicate]

On the bash prompt one, three or more slashes (/,///,////, ...) are treated as a single slash, whereas two slashes (//) are left as is: 12:07 $ cd / 12:07 $ pwd / 12:07 $ cd // 12:07 $ pwd // 12:07 $ ...
1
vote
1answer
16 views

'hhighlighter' wrapper script saying command not found

I have gotten the wrapper script 'hhighlighter' from https://github.com/paoloantinori/hhighlighter which colors anything you want in stdout. I followed the instructions about installing ack-grep, ...
2
votes
1answer
23 views

Command Line Macros in Comments using SLURM

In my opinion, comments are comments are comments. They should NEVER change program state. Sadly, the people over at SLURM disagree. SLURM requires the following syntax (or something similar) to ...
0
votes
1answer
42 views

Bash script class path issue with java

jvm.script.sh /opt/scripts/jvm/jvm.script.sh #!/bin/bash JAVA_HOME='/java' PATH="$PATH:/$JAVA_HOME/bin" java -cp ./classes:./lib com.mystuff.bar.foo.myclass & init.script.sh ...
0
votes
3answers
64 views

How to print only certain characters?

I have to translate the permissions of a file this way: r ► c w ► s x ► e Then, I must extract the group of characters which are related to owner group. Last step is to print that group of ...
0
votes
2answers
54 views

Help in starting learning bash script [on hold]

I have just started analyzing sequencing data using Linux. I have created a pipeline for variant calling that includes eight commands or maybe more. I need to paste every command one by one and wait. ...
0
votes
1answer
49 views

Editing lines in a file using a bash script?

I am creating a bash script that installed VSFTPD / FTP. After the installation some configuration is required in the "/etc/vsftpd/vsftpd.conf" file. This includes making sure the following lines are ...
1
vote
2answers
64 views

Sort files according to their extensions

I have made a script that will sort files according to their extension and place them in the proper folder. For example, place abc.jpg in the directory jpg. #!/bin/bash #this script sorts files ...
0
votes
2answers
25 views

How do run MYSQL scripts from a shell script with bash variables?

Im making a script where I connect to a database, look for a value and then if that value returned something then I will do something else. ip=$("variable is defined here") Then I connect to the ...
3
votes
2answers
106 views

single quote within double quotes and the bash reference manual

In section 3.1.2.3 titled Double Quotes, the bash manual says: Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception ...
12
votes
2answers
763 views

How can variables use “~” for cd'ing?

How can I use a variable - $BASE in my cd. I tried the following but I get an error $ cd ~/z/repo_1_ruby_193/ 23:23:57 durrantm Castle2012 /home/durrantm/z/repo_1_ruby_193 $ BASE="~/z" 23:24:03 ...
0
votes
0answers
48 views

(Solved) Bash Graphical uninstaller using a tool to make graphical my script [on hold]

I have a problem with logic on this part of my script, I can't see my fault. . Basically the script must be do the follow: Well when i click "Yes" its "Yes" when i click "No" , its "Yes" , i dont ...
0
votes
0answers
17 views

Bypassing the security message in Debian 7 when creating a bash script? [duplicate]

I've created a bash script which involves the installation / update of wget. As a result there is also a message from Debian showing the following: wget (1.13.4-3+deb7u2) stable-security; ...
1
vote
2answers
39 views

Oneliner which prints groups and their numbers which start with a '1'?

I have to write an oneliner which print system groups and their identifiers, for all groups whose identifiers start with '1'. For example, the result of cat command on /etc/group is this: I must ...
0
votes
0answers
16 views

Should all other versions of BASH be uninstalled after patching with the latest version?

My system (slacko puppy 5.7) still tests positive for shellshock after installing the latest version available (bash-4.2.053) I see that old versions are still installed (bash4-4.41_spup and ...
1
vote
2answers
130 views

How to grep for something that's in an environment variable and has a forward slash?

I want to grep a file, and I want to get all the lines that have a certain environment variable (to be exact, $PWD). Of course, using just cat file | grep '/'$PWD'/' is not working, since $PWD ...
1
vote
0answers
26 views

Having problems running a script thats built up through the script [on hold]

I am currently making a script that sets variables and then runs a script. Here is a bit of what it looks like: #!/bin/bash xml='<This,is,hidden,because,of,personal,information><Id>' ...
4
votes
5answers
160 views

Calling multiple bash scripts and running them in parallel, not in sequence

Suppose that I have three (or more) bash scripts: script1.sh, script2.sh, and script3.sh. I would like to call all three of these scripts and run them in parallel. One way to do this is to just ...
3
votes
5answers
75 views

How to show distinct directories on find?

I want to find all directories containing, for example, files named *.txt. but the output must not contain duplicates. How to do it?
1
vote
2answers
41 views

Why double ampersand chained conditions runs in background together the last one?

I have some conditions for some background job to run: condition-command && condition-command && background-job & The problem is: I want the conditions to block until the job ...
1
vote
1answer
24 views

Updating a bunch of Macs via SSH. Could use some help

all. I'm working on a script that'll be running from our Mac server, and it will (hopefully) update all of our Macs via Munki (repo is on the same server) and the built-in softwareupdate command. ...
4
votes
4answers
162 views

How to capture command line input into logfile and execute it at the same time?

Let's say I issue some commands on the command line: #capture what follows $ echo "foo" foo # don't capture $ echo "bing" bing # capture again $ echo "bar" bar How can I log commands selectively ...
2
votes
1answer
24 views

Problem with either su username -c “./script.sh” and sudo -u username bash -c “./script.sh” and Java classpath

I am seeing some strange behavior that has led me to wonder how the environment differs when running either of these 2 commands, versus using su username and then running the commands as the user one ...
1
vote
3answers
65 views

0 byte file created in a simple script

I have a script as below: #!/bin/bash df -k | tr -s " " "," | awk 'BEGIN {FS=","} {print $1,$5}'|sed 1d > file1.txt while read partition percentUsed do if [ $percentUsed > 75 ] then echo ...
0
votes
2answers
50 views

select a file under a directory? [closed]

In bash, when being under a directory, how can we select a file or subdirectory without actually typing its name or even part of its name? Is there a way to enumerate or alternate the files or ...
7
votes
4answers
322 views

output to file, then use file for input

Is there a shorter way of writing this? Basically output a command to a file, then use the file as input for the next command. I also want to keep the file to view afterwards. cmd1 > verylong.txt; ...
0
votes
1answer
14 views

Scope of shopt options in cron script

I have a bash script that is run nightly in a cron job. It needs to do case insensitive file matching, so the script calls shopt -s nocaseglob I want to make sure this does not affect other cron ...
2
votes
1answer
47 views

Bash Array Comparision

Within a bash script, I am building two dynamic arrays. And I want to construct another array with difference of two. Example: array1=("aa-1234|safsf|sfsfs" "aa-2345|sfsfs|n0sfm" ...
2
votes
3answers
210 views

Bash File existence test is always true

I have the following lines of bash script to test whether a file exists: MYAPPPATH=$(find $APPDIR -iname myapp* -print) if [ -e $MYAPPPATH ] then echo "File exists" fi However when file ...
3
votes
2answers
30 views

How to print a range of IP addresses with Linux seq command

How can I print a range of ip addresses on linux command line using the "seq" command? For eg: I need seq to print a range of ip from 10.0.0.1 to 10.0.0.23 . Seems like the period in between the ...
5
votes
3answers
539 views

Shorter command for deleting files

Our web server was originally maintained by a different company. They wrote a short script to clean out cache files. Their file has several lines that read like this: /usr/bin/find ...
3
votes
0answers
77 views

Bash Script - Wget Graphical Download Progress

I'm trying to port this code from wget + zenity to wget + kdialog. The code with zenity: #!/bin/bash # Start wget | zenity # Note the & at the end of the pipe, this allows the script to continue ...
3
votes
3answers
105 views

Why is my script calling multiple functions? [duplicate]

I am new to writing scripts in bash. My script is simple, I have a few sets of scripts that I've written to make setting up linux very simple. So I have made those scripts into separate functions ...
0
votes
1answer
11 views

How to script with systemd-cgtop?

The manpage for systemd-cgtop says that if there is no attached tty it will do one iteration and then print it out, saying that this would be useful in scripts. However when I try to do this from a ...
1
vote
1answer
28 views

bash completion: how to complete a list of hosts for a specific argument?

My programm can have the following format: <command_name> <arguments> <options> -hosts <host1> <host2> ... <hostn> (<more_arguments>) ... I am trying to set ...
2
votes
2answers
58 views

Inputting user input automatically through bash script? [duplicate]

I am creating a bash script which creates a user and sets a password. When the command "passwd user" is run it requires the user to enter a password and stops my script. Is there any way to fulfill ...