Bash is a free shell for Unix-like operating systems from the GNU Project.

learn more… | top users | synonyms

3
votes
1answer
708 views

Float integer division and setting variable value

I am currently learning the world of bash scripting. I am aware that bash by itself does not do arithmetic with floating integers. I have done some research and have found that there are tools that ...
23
votes
1answer
5k views

How to get infinite command history in bash?

I set export HISTSIZE=99999999999999 but is that the best way? I don't know if an overflow might occur. I'm looking for a tested, reliable way to remove command history limits.
1
vote
1answer
21 views

How can echo the previous command I ran to a file?

I tried running echo '$(!!:p)' > /tmp/tmptxt.txt, however I just get $(!!:p). The previous command may have unescaped characters so I i need to escape it.
8
votes
1answer
8k views

command-line utility to record from microphone

I am looking for command-line utility that monitors the microphone, and if you start to speak, writes the file. Recording period should be adjusted. Solution is: sox -t alsa default recording.wav ...
1
vote
1answer
34 views

Clear console buffer in ConEmu with Cygwin

I've recently switched from using iterm in OSX to using Cygwin in ConEmu on Windows. One thing I'm really missing is the ability to completely clear the terminal buffer at any time using Alt+k. I've ...
2
votes
2answers
140 views

How to delete old $PATH echo in Mac

After i changed my Mac username(using the way supplied by Apple Documents), I found that when echo $PATH, there are some old paths in it. ...
0
votes
0answers
11 views

Can a subprocess launched from a parent executable access the memory of its parent?

Given a system() call with user controlled input, is it possible to read the virtual memory of the parent program? Assume that the system call is made with dropped privileges, and that running ...
1
vote
1answer
38 views

How to daemonize a bash script only if --daemon flag is given?

I have my script.sh and want to run it with ./script.sh or ./script.sh --daemon, having it remain in the foreground unless the --daemon flag is given, in which case it should detach and go into the ...
79
votes
2answers
74k views

How do I change my default shell from bash to zsh?

I want to change my shell from the default bash shell to zsh on my Amazon EC2 instances. How do I go about doing it? Thanks!
1
vote
1answer
92 views

Execute script on login Fedora 21

I'm trying to launch a script located in my home directory when I login on Fedora 21. I have tried to make this desktop file in /usr/share/autostart [Desktop Entry] Type=Application Name=Wallpapers ...
0
votes
3answers
27 views

Parameter substitution in sh -c

I have a large number of log files, the idea is to group them by date/month and then pack into archives. Here's my script: find /c/this/path/ -type f -name "$file_pattern" | xargs -I fn basename fn ...
-1
votes
1answer
46 views

Bash script to store words from file in different variable [closed]

I have a need to store words form file in different variable. Like I have a file test.txt containing below content: uname : null empty amarjeet sharma ver : null 1.2 empty 1.3 1.4 txn : null 123 ...
0
votes
3answers
132 views

Replace string in string but not when its somewhere between double square bracket

I have a long string from mysql field containing the data of a mediawiki page. I have to replace a string in that mediawiki page but not when the string is in mediawiki link. The mediawiki link is ...
1
vote
1answer
23 views

Why is bash adding spaces and stretching out filenames in Arch Linux?

My Arch Linux laptop is creating some strange output when using bash. It puts spaces between characters and stretches out files names. I’ve tried to remove/reinstall bash-completion but nothing ...
7
votes
1answer
631 views

What is a safe ping frequency without it being considered a DDoS attack?

I am trying to chart the uptime of a server by regularly pinging it and Google and then comparing the ping times. I want to keep doing this over a period of—let’s say—a week. I am sending a set of 5 ...
1
vote
2answers
22 views

How to make sed print to the end of line from socat

I have a server which sends data in a UDP Broadcast on port 10552. The data is 7 numbers separated by commas as so. 5.351204,0.001968,-0.000473,-0.999222,0.000451,0.001455,1.084310 I fetch this ...
0
votes
0answers
27 views

etherwake fails to run when ran by cron

I have a cron job to check if a client is connected to my VPN and then wake up some other computers on my network using etherwake. I have the script running every minute and it is actually running ...
15
votes
7answers
7k views

How to retrieve the absolute path of an arbitrary file from the OS X

I'm looking for a simple command that can be used within Bash to find the absolute and canonicalized path to a file on an OS X (similar to `readlink -f' under Linux). The following sample bash ...
1
vote
0answers
46 views

How to download files from Website using bash [closed]

I am trying to download a collection of files from a website. Where the collection is drawn from "TAGS". I have tried using many combinations of wget and bash scripts with no luck. Each file is nested ...
2
votes
0answers
17 views

Can one start shell from save file dialog

Using ubuntu. If one tries to print to a file, the save dialog opens. Is there a way one can execute the shell (or terminal) from the save file dialog file name entry box?
5
votes
2answers
2k views

Delete all files older than X days

So I have a cron setup to make backups of a folder into a tarball every hour. I would like to add into the shell script that I'm using the ability to have files deleted automagically after about three ...
1
vote
1answer
29 views

Escaping asterisk * in Bash on Windows

The following command works in GNU Bash on FreeBSD but not in Git Bash on Windows: curl -X PUT https://example.com/_config/cors/origins -d '"*"' The intended result is to send a PUT request to ...
2
votes
1answer
41 views

No available formula for “pdfunite” in Homebrew?

I am on Mac OS X 10.10 (Yosemite) and I am new to Bash. I am trying to install pdfunite. I installed Homebrew and ran the following command: brew install pdfunite And I received Error: No ...
0
votes
1answer
71 views

How can I delete the content between two tags in a large xml file (>2GB)

The File in Question is XML but I want a Shell Script to remove all the binary (Base64) encoded images that are embedded. The files are generally huge (>2GB). I want to delete everything between: ...
1
vote
0answers
27 views

cp: cannot stat error - when filename has Asian characters

I am simply trying to copy files using cp -r /home/user/source/ /home/user/destination/ but it throws me the cp: cannot stat /source/filename.xxx error for some of the files. When I searched for this ...
0
votes
1answer
28 views

Why is grep missing missing matches when searching multiple directories?

Trying to grep the files in several child directories, grep returns nothing. ~/box/raw $ grep ":2259\"" f*/hh*.adt ~/box/raw $ But when I descend into one of the child directories, grep finds a ...
0
votes
0answers
19 views

Readline stops working randomly

For some reason every 1-3 hours (depending on work load) my shell read command stops accepting input and hitting return renders the ^M character. Something like: Continue? After answering: ...
0
votes
1answer
18 views

Unix/linux shell scripting floating point division

I have to divide two floating point values and store it in variable. My code below v_missedvol=4003.03 v_allvolume=3003.03 v_vol_temp= $(echo "$v_missedvol / $v_allvolume" | bc -l ) the result ...
2
votes
2answers
1k views

Shell script to rename multiple files from their parent folders name

I have a file structure like this: 00000010 000000001.file1 000000001.file2 00000020 00000003.file1 00000003.file2 00000003.file3 ... So there are folders with 8-digit names containing one ...
1
vote
3answers
3k views

How to disable trackpad/mouse via the Mac OS X command line?

Is there a terminal command in Mac OS X to disable/enable the trackpad/mouse? I know that I can disable the trackpad of my MacBook Pro when an external mouse is connected. But is this also possible ...
0
votes
2answers
612 views

Downloading and extracting a .tar to a specific directory

I want to download a tar of a git repo and extract its contents to another folder. The following line (broken up for clarity) works: curl -L -0 nt-dotfiles.tar.gz ...
51
votes
10answers
54k views

Remove a certain line from Bash history file

How can I remove a certain line from history's database?
1
vote
0answers
20 views

monitor command outputs in separate windows within a terminal

For a list of input text, I want to execute a repetitive command using each element from the list. In addition I also need to monitor the results of each of these commands in parallel. So I am looking ...
35
votes
4answers
13k views

Bash: Spaces in alias name

I am trying to create an aliases in bash. What I want to do is map ls -la to ls -la | more In my .bashrc file this is what I attempted: alias 'ls -la'='ls -la | more' However it does not work ...
0
votes
2answers
51 views

bash shell error: “no such file or directory”

I am trying to install Virtualenv wrapper on Ubuntu 14.04. But whenever I start a terminal, I get the error saying bash: /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh: No such file or ...
0
votes
1answer
24 views

Wget not getting cookies, not pulling back results in check.

I'm having a couple of issues when porting check scripts between a couple of servers. The script. #!/bin/bash hostname=$1 port=$2 retstatus=0 retStr= st=`date "+%s.%N"` if [ $# -ne 2 ]; then ...
0
votes
1answer
32 views

Output of the ps command and understanding the flags

Ubuntu 12.04 LTS using bash. I tried running the ps command from a Java program using the Runtime and got some unexpected output. Upon closer inspection I realized that it was the output of: ps ...
0
votes
2answers
37 views

sh -c in background

Original version: How to run sudo sh -c "command" in back ground In a terminal sudo sh -c "command" & starts in background but as soon as I press enter, the process exits [test@localhost ...
10
votes
5answers
25k views

command not found when using sudo

There are a few question on the site that seem related to my problem but I could not find a solution in any of them. My operating system is Ubuntu 12.04. I have mvn installed in ...
0
votes
1answer
20 views

How to include a call to ncat to a bash script?

I need to flush a memcached instance from a bash script, I found the following command which do the job: echo 'flush_all' | ncat localhost 11211 But my problem is that the script doesn't continue ...
1
vote
3answers
1k views

How can delete all files except one from a directory?

I need to delete all files, except one (its name is defined), from a given directory. How can I do this from the terminal in OS X? Can I do this with one single command?
0
votes
0answers
18 views

Mac terminal lost git knowledge

When I opened terminal and went to a git repo, it would automatically show the branch I'm on with a big green check or red X if I had any changes. Logged onto machine today and my bash profile was ...
4
votes
3answers
816 views

How do I edit previous lines in a multiple line command in Bash?

When entering a command which spans multiple lines in Bash, how do I edit previous lines? I'm a Linux Mint (Lisa) user using GNOME Terminal. For example, let's say I type: $ echo "foo bar > baz ...
0
votes
3answers
51 views

du -sh : I don't get why these two results are different

I need to know the size of a folder and some of its sub folders. So I'm trying to use the du command. I cd into the right directory and then try (in bash) : [xxx@yyy TEST]$ du -sh . 4.1G . ...
0
votes
2answers
27 views

Bash command for replacing all non-printable characters?

I have a bash script that checks database for changes and emails me these changes. Works nice, until it tries to send something non-printable, which 'breaks' the mail. Is there any handy way how to ...
1
vote
1answer
43 views

Bind a key to newline in Bash, without submitting command

I want to press M-j and have readline place my cursor on the next line without entering a command. Thus I should be able to go back a character onto the prev. line. This answer states that it cannot ...
7
votes
4answers
13k views

How to remove all files starting with a certain string in Linux

I need to find all files starting with the name NAME in a directory tree and remove all these files using one shell command.
1
vote
2answers
2k views

“ls” shows no files in mounted NFS folder, but “cd” works

An NFS share was mounted to /vol/mynfs on a Linux client. It does not show any folders with ls and bash completion does not work in /vol/mynfs too. But after changing to a subdirectory all files are ...
-1
votes
1answer
32 views

bash script doesn't work unless bad command given

I have a script that doesn't work (it freezes my status line) until it is completely done. However, by adding a random bad command, e.g. asdfasdf anywhere in the file that the script reaches (i.e. ...
0
votes
2answers
20 views

list file and using awk to get comment

I want to get the all comment of all files in a folder. And what I have tried is ls -R | awk '/<!--/,/-->/' >> result But it shows nothing in the result file. But if I use the awk ...