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
1answer
3 views

'Tar' the result of a 'find', preserving the directory structure

I want to tar all the *.txt file, that I get from the result of a find, that exist into a directory having a tree like this: Directory_name dir1 file1.pdf file1.txt dir2 file2.pdf ...
3
votes
2answers
306 views

Using `select` command to print menu in Linux

I am trying to implement a simple menu using select command. The script (for testing purposes) is as follows #!/bin/bash echo "*******************" PS3='Select an option and press Enter: ' ...
3
votes
3answers
887 views

Bash script needed to run every second

I have a few cleanup commands to run for my datacaching scheme. I was thinking a bash script would be an easy way to check if the full clean up job needed to be run. But the cache is very time ...
0
votes
3answers
30 views

iterate lines containing zeros in bash

I am having a file which looks like this: 141.519 141.009 140.121 135.519 0 0 0 0 I'm writing a shell script and I want to replace all lines containing a zero with -1e+10. So far, I’ve tried this: ...
1
vote
2answers
39 views

Bash: issuing trap twice

I have a very simple question. I can't believe the Bash manpage doesn't explain this already, but anyway... If I issue the trap builtin twice [for the same signal], what happens? Is the second ...
1
vote
4answers
169 views

Replace string repeatedly

When I execute command sudo iwlist wlan0 scan | grep ESSID resulting ESSID:"DHS_3RD_FLOOR" ESSID:"MAXTA" ESSID:"MAXTA_5THWL" ESSID:"OPENSTACK" ESSID:"IOT" ESSID:"ved_opa" ESSID:"dlink" ...
2
votes
1answer
39 views

Execute command that was displayed on the screen as a message

A message is displayed many times on the screen after entering certain command. I need to retype the entire suggested command or copy and paste it. Is there a shortcut to do the same using the ...
4
votes
4answers
6k views

Is there an online bash script testing site?

Sometimes I need to help friends with bash scripting. When I'm on a Windows machine, it's a working environment and I can't just setup Cygwin or use a VM. Is there some free scripting website I can ...
0
votes
1answer
36 views

.bash_history keeps truncating

My .bash_history keeps truncating even though I set: export HISTSIZE= export HISTFILESIZE= On my .bash_profile. Im not sure when it happens but it might happen when I logout or shut down my ...
112
votes
15answers
55k views

How to do integer & float calculations, in bash or other languages/frameworks?

Using echo "20+5" literally produces the text "20+5" What command can I use to get the numeric sum, e.g. 25 in this case. Also, what's the easiest way to do it just using bash for floating point, ...
-1
votes
0answers
45 views

Scripting multi-volume (GNU) `tar` with pre-defined number of volumes

I've wrote me a little script to test (or extract) a very big multi-volume tar archive (note: created with GNU tar), each of which 00x.tar chunk will fit onto a standard DVD: #!/bin/bash d=$(dirname ...
1
vote
2answers
118 views

Can I hook into the cd command?

I'm trying to set something up on a server I run, when ever I cd into a public_html folder 95% of the time there's a few commands I will always run to check certain things. Is there anyway I can hook ...
0
votes
0answers
17 views

Get similar links from one site using wget [on hold]

I have a site (http://a-site.com) with many links like that. How can I use wget to crawl and grep all similar links to a file? <a href="/user/333333/follow_user" class="btn" ...
6
votes
4answers
368 views

List the number of lines in files

How can I list the number of lines in the files in /group/book/four/word, sorted by the number of lines they contain? "ls -l" command lists them down but does not sort them
27
votes
2answers
2k views

How does `cat <> file` work?

cat < file prints the contents of file to stdout. cat > file reads stdin until Ctrl+D is detected and the input text is written to file. cat <> file, at least in my version of Bash, ...
2
votes
2answers
59 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 ...
1
vote
2answers
1k views

Command not found problem in Linux-Ubuntu terminal

My friend is having problem in trying to call make to compile an application which both me and a second friend have previously successfully compiled. The file uses a "linux-devkit" pack that possess ...
0
votes
1answer
36 views

How to create a script to run several scripts on different servers

I need to automate the execution of several scripts, and I'm writing a script. The scripts have to run concurrently because they are part of a benchmarking suite. I'm trying to execute 6 different ...
6
votes
3answers
2k views

Displaying seconds as days/hours/mins/seconds?

Is it possible to easily format seconds as a human-readable time in bash? I don't want to format it as a date, but as the number of days/hours/minutes, etc...
0
votes
1answer
11 views

Virtualbox vboxmanage clone does not show up in virtual machine list

I have a virtual machine that I am cloning with the command line interface to virtualbox like so: vboxmanage clonevm origVM --name origClone However, the clone is added to the directory ...
2
votes
0answers
12 views

Programatically / dynamically adjust SSH session port forwards

I have a workflow where I am trying to do the following: For a given existing SSH session, access the remote machinne and perform a process from which a port is returned (e.g. a remote daemon has ...
4
votes
2answers
5k views

How can I make PuTTY compatible with Solaris?

I'm connecting to a Solaris machine from WinXP using PuTTY. When I try to use the NumPad keys for editing a command in Bash (Home, End, Delete) a ~ character is instead printed to the console. ...
11
votes
3answers
271 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 ...
4
votes
3answers
5k views

bash: /home/user/.ssh/authorized_keys: No such file or directory

Create a ssh key: $ ssh-keygen -t rsa –P "" Moving the key to authorized key: $ cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys bash: /home/user/.ssh/authorized_keys: No such file ...
76
votes
8answers
89k views

Colorizing your terminal and shell environment?

I spend most of my time working in Unix environments and using terminal emulators. I try to use color on the command-lin, because color makes the output more useful and intuitive. What are some good ...
2
votes
3answers
31 views

How to parse env variable in a quoted string?

I'm having a hard time getting the value of an environment variable ($GHREPO) in a quoted string. Here is the command I'm running. I'm trying to make a directory with the value of ...
2
votes
3answers
1k views

Using a here-doc for `sed` and a file

The title says it all, I want to use a here-doc for sed commands and provide the file to be read and the output file. I've looked at Here-Documents from Advanced Bash Scripting guide but it does not ...
1
vote
1answer
36 views

change a bash script while it is running [duplicate]

I have a script test #! /bin/bash sleep 60 echo hello I ran it by setting it executable and ./test, and while it was running the sleep command, I changed it to #! /bin/bash sleep 60 echo ...
3
votes
1answer
18 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 ...
4
votes
2answers
82 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 ...
1
vote
3answers
50 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 ...
1
vote
1answer
5 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 ...
7
votes
4answers
326 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
20 views

Confusion about basic bashscript loop - until/done [duplicate]

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 ...
-2
votes
0answers
33 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
vote
0answers
5 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 ...
7
votes
3answers
411 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 ...
0
votes
0answers
41 views

Why does SPACE sometimes not work with more (or less)

Usually with |more I press space to get another screenful. But with some commands space just does nothing, and I need to actually keep doing SPACE-ENTER to scroll forward a screen at a time. Both more ...
0
votes
1answer
48 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 ...
-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
1answer
19 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
0answers
29 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: ...
6
votes
3answers
4k views

What is signal 0 in a trap command?

I'm following this guide on how to set up passwordless SSH authentication with ssh-agent. To start up ssh-agent the author recommends the following code in .bash_profile: SSHAGENT=/usr/bin/ssh-agent ...
1
vote
2answers
3k views

Use inotifywait to move file when it loads in dropbox folder

I'm trying to find a way to immediately move a file to another folder as soon as it appears in my dropbox on CentOS. I have scoured the internet for some clues but I can't get any further than the ...
0
votes
1answer
26 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 ...
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 ...
2
votes
3answers
2k views

cshrc execute bashrc within itself?

My school has our Linux accounts using csh/tcsh by default. I, however, have a lot setup on my home bashrc and I'd like to use that at school. BUT there's also some important stuff that happens in our ...
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 $ ...
0
votes
3answers
66 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
55 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. ...