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

learn more… | top users | synonyms

2
votes
1answer
116 views

Script acting strange in bash_profile (but just under X)

I have made a simple .sh script which checks every minute whether a particular file is empty or not, and if it is not empty, makes a led on my laptop blink at 0.5Hz. I call this script from my ...
5
votes
2answers
817 views

How to use GNU parallel with gunzip

I have a directory full of .gz, I want to expand each archive in parallel with GNU parallel. However I did not achieve anything. I tried parallel 'gunzip {}' ::: `ls *.gz` parallel gunzip `ls *.gz` ...
0
votes
1answer
1k views

Send mail with an zip attached from Mutt without prompt options?

I'm stucked when I'm trying send an email, using Mutt, but evry times that I run the script it prompt an menu with an verification. There is any way to bypass that verification or to inupt the option ...
1
vote
1answer
1k views

tcpdump output to file not working

I'm trying to write the results of tcpdump to a text file. I am not interested in saving a pcap file to use later, I just need exactly what tcpdump returns in plain text (the ips and timestamps of ...
6
votes
5answers
16k views

Monitor TCP Traffic on specific port

I've searched quite extensively for this, but cannot seem to come up with a working example. My objective is to monitor TCP traffic on a specific port to see incoming connections and write them to a ...
0
votes
2answers
611 views

Run a bash script on boot of ubuntu server which does a constant loop

I am in the middle of create a local FTP server and I need this script to run when the machine boots up: #!/bin/bash while [ 1 ]; do chmod 2777 /home/ftp/folder; chmod -R 777 /home/ftp/folder; sleep ...
3
votes
2answers
468 views

How to execute a function in bash or zsh on every letter being typed into prompt?

I know about preexec() hooks for zsh and the way this can be achieved in bash. ( link ) But can i get the current input while still typing? The idea behind this question is the following: in order ...
3
votes
2answers
194 views

Manually update the mtime of a file in UNIX

Is it possible to manually alter the date of a file on a UNIX system (to a previous date)? If so, how would I tackle this problem? How would I be able to do the same thing on multiple files at the ...
0
votes
1answer
571 views

bash can't find sudo command on friendlyarm

I'm trying to work with this friendlyarm 9 board I got recently but it can't find some basic bash commands and I couldn't find a solution for it anywhere. When I type any command with sudo or even ...
0
votes
2answers
559 views

bash: variable name not being expanded with Tab completion

On a remote computer with bash version "3.2.51(1)-release" (OS: SUSE Linux Enterprise Server 11.1 (x86_64)), I could not do a usual tab completion with variable name. for example, I'd like to type: ...
1
vote
2answers
158 views

How do I make an alias work when I need to invoke more than one binary in the same command?

Say I have two binary files: binary1 and binary2. Each of them has its own option set: options1 and options2. Users need to invoke a command that follows this structure: binary1 options1 binary2 ...
4
votes
2answers
151 views

Create directory of files each with a certain file size

I would like to create 100 files each with a file size of 10Mb. Is there a simple unix command that can create a directory with these 100 files?
1
vote
2answers
65 views

How do I run Windows vim from a function within my .bashrc?

I have installed windows vim and added the following function to my .bashrc: function winvim() { local win_vim_path='/cygdrive/c/Program\ Files\ \(x86\)/Vim/vim73/vim.exe' #local ...
1
vote
1answer
104 views

Backup many files by keeping all old versions

My question is about saving many files from many directories in only one directories by keeping all old versions of the files. I have about 10 directories with very similar files (10 backup ...
0
votes
1answer
253 views

How to extract a record in a text on string match in a file using Bash

I have a text file sample.txt as: =====record1 title:javabook price:$120 author:john path:d: =====record2 title:.netbook author:paul path:f: =====record3 author:john title:phpbook subject:php path:f: ...
2
votes
3answers
154 views

How do I prevent $PATH from resetting itself each time?

I'm having difficulty setting up the PATH on my macbook pro. I followed this link to modify my path variable. Each time I start a new terminal I get a PATH pointing towards ...
4
votes
1answer
29 views

Shell - how to go to a location that is just returned by previous command?

After I do $ which play $ /Users/username/local/play/play Is there a way that I can access the shown directory quickly without manually typing the directory by hand? Just curious :)
0
votes
1answer
376 views

Streaming log file contents (piping)

I am trying to understand how piping works and am stuck at this point. A log file is being streamed and its output is being piped to pigz. What I am trying to do is, redirect the pigz content to a ...
0
votes
2answers
127 views

Replacement for sed and 'open' in windows

I have the following bash script that takes a text file and opens a tab in the default internet browser with a google query (after some clean ups) per line. I want to make a version of this script ...
1
vote
1answer
206 views

Alias stopped working after SSHing into Ubuntu machine

I am facing a problem with Ubuntu. Bash aliases like ll are not working if I am logging to my system from SSH. It works fine after writing bash as a command in the shell. It used to work. What ...
3
votes
2answers
3k views

Renaming with exiftool: how to deal with missing tags?

I'm dealing with an unorganized, big group of media files, captured using several different cameras and camcorders, and I'd like to use exiftool in a bash script to rename each file with its creation ...
1
vote
1answer
250 views

Why the here-strings in bash are slower than piping the input to a command?

I compared the execution time for unix here-strings and pipe data input to bc: pipe time for i in {1..1000} do echo "sqrt(5.09)" | bc -q > /dev/null done real 0m3.584s user ...
3
votes
1answer
1k views

Ping server/domain and capture its IP on Linux

With Windows, you could ping a given domain name and capture the IP as a variable, even if no reply was received. I believe the command looked something like this: ping domain.com for /f "tokens=1,2 ...
2
votes
1answer
822 views

Ubuntu RFID Screensaver lock-unlock

So, I have this el-cheapo RFID scanner and some RFID tags. I thought to myself, You know what would be neat? Enabling and disabling the lock screen with this thing. So the package arrived and I tore ...
5
votes
2answers
8k views

How to get CPU percentage and memory usage on single line?

How can I obtain CPU percentage usare and RAM percentage printed out in one line on linux? (Using cli) I have to pass these output string to an LCD display. Thx a lot
0
votes
1answer
44 views

iTerm2 not respecting my key bindings…sometimes

I have my iTerm2 keybindings set to have command+left arrow and command+right arrow move the cursor to the beginning and end of the line. This works most of the time. But not when I am in ghci (the ...
0
votes
1answer
598 views

ls not using the LS_COLORS environment variable

I am using the configuration below for ls. I have changed the $LS_COLORS variable to display directories as cyan colored using di=01;36. However, when I run ls, directories show in purple. If I run ...
1
vote
1answer
927 views

Making a bash script to compile / execute C++

I'm trying to make a simple script that will compile test.cpp but I cannot get it to work. I'm running the script like this: > bash make.sh And getting the following error: : No such file or ...
0
votes
1answer
29 views

Bash behaviour customisation

I'm using GNU Bash 4.2.5 with fedora 18. Whenever I'm typing something into the shell say pe<tab> I get an annoying error sound, I then have to press tab again to view the auto-complete ...
3
votes
2answers
741 views

How can I disable that “Display all possibilities” and --More— stuff in bash?

In my shell, l + tab completes like: wim@wim-zenbook:~$ l Display all 135 possibilities? (y or n) With a prompt, and then I have to answer y or n which is annoying, it pages through with --More-- ...
0
votes
1answer
28 views

how to restore tmux last application

I have been using tmux for a while. one thing is very annoying me is that there is a way to restore last time application. for example: in my current tmux session, I have three windows (two running ...
1
vote
1answer
70 views

How to determine full command with args given a pid (or port in use)

I've got this nice bash function for telling me the pid using a port: using_port() { lsof -i:${1} } Output looks like this: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ...
3
votes
1answer
1k views

Use bash script to copy select txt files from remote server to my local machine

I would like this script to NOT prompt me for a password when I run it. I would like to put a password inside the script that will pass by itself. This is not a root password: It is for an account set ...
4
votes
4answers
979 views

List of all the users that logged in using GUI or Command Line

I need to calculate the total time that a specific user stay logged in per day. And stop user using the computer more than the time allowed by shutting down the system. uptime cannot be used since ...
0
votes
2answers
1k views

How do I recursively go through directories and name a file after the directory?

What I am attempting to do is combine all of the files within a subdirectory into a new file, and give the new combined file the same name as the subdirectory, and I have no idea how to do this in ...
0
votes
0answers
53 views

How do I script a config file change

I'm trying to create a script to make the vi color change described here http://www.kavoir.com/2009/05/how-to-change-vim-syntax-highlighting-colors.html Trying to do it with sed but it's not working ...
5
votes
1answer
1k views

How to properly create symbolic link?

scenario : I'm in a place that is not in PATH I have a file name dofoo that is executable I want to create symbolic link in /usr/bin that points to dofoo in current directory quite hard to get the ...
2
votes
3answers
340 views

How to use grep to search for regular expressions themselves, without parsing them

grep . filename.txt This just returns all of the contents in filename.txt, because . is a regular expression that stands for any character. How do I use grep to search for periods, or other regular ...
0
votes
1answer
154 views

profiling file reading speed via /dev/null?

I am profiling the speed at which a certain Linux program reads a certain input file using different amount of threads by doing this: time ~/src/myprogram -t $t inputfile 1>/dev/null ...
22
votes
7answers
3k views

Is there a standard unix program that returns a range of numbers

Im learning shell scripting from an outdated textbook, and it seems to me like it'd be really usefull to have a program that just returns a string of numbers delimited by spaces something like $ ...
1
vote
1answer
259 views

Changing the case of the Nth character of a filename using Bash?

I have a folder of files and I want to change the case of one of their characters at the 5th position. From this: ABC-xyz DEF-xyz GHI-xys To this: ABC-Xyz DEF-Xyz GHI-Xys You'll notice the X ...
2
votes
1answer
223 views

Terminal shows “launchctl usage: setenv <key> <value>” on top of every session

Every time I open a Terminal window the following is printed on the top: launchctl usage: setenv <key> <value> I figured something must be wrong with my .bash_profile but I could not ...
17
votes
1answer
11k views

Remove single file from zip archive on Linux

I have a zip archive (created automatically in a script with -j -r flags) and I would like to remove a single file from it. I tried as documented. zip -d "picture_43_9.jpg" gallery.zip but I get ...
0
votes
1answer
653 views

Mac OS X login script for specific user

I need to be able to run a bash script every time a specific user logs in. The solution here is for all users. Is there any way to specify the user, and if not is there a way for the bash script to ...
2
votes
1answer
212 views

How to use the $_ positional parameter in the fish shell?

In Bash, the positional parameter $_ holds the last argument in the previous command: $ /home/joe> some-script foo bar $ /home/joe> cd $_ $ /home/joe/bar> The positional parameter $_ does ...
3
votes
2answers
805 views

Why is xargs necessary?

Suppose I want to remove all files in a directory except for one named "notes.txt". I would do this with the pipeline, ls | grep -v "notes.txt" | xargs rm. Why do I need xargs if the output of the ...
0
votes
1answer
238 views

vim set default to save buffer when TERM signal received

I use multiple instances of vim. Currently I use a bash function kv(){ a=($(pgrep vim)); kill ${a[@]}; } to terminate all running instances of vim. This has the drawback of leaving unsettled ...
0
votes
0answers
49 views

Can FIGNORE be limited to specific applications?

I know that you can use FIGNORE to remove filename completion from suffixes. For example, to avoid a lot of garbage files produced by LaTeX, I've been using: ...
1
vote
2answers
469 views

Why does xmessage report that user clicked 'x' without displaying message when run from cron?

I have the script below, which seem to work perfectly when run from the commandline with /root/.scripts/peter-laptop-backup-launcher.sh daily (it displays an xmessage asking what I want to do), but ...
0
votes
3answers
147 views

Knowing Command Lines in Ubuntu [closed]

I want to know if any references out there I can follow-up in everything that's going on in GNOME-Terminal I'm studying to be a web developer and I'm going to be making the jump to Web Administer I ...