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

learn more… | top users | synonyms

4
votes
4answers
4k views

How to ignore error messages in bash on Ubuntu?

I'm trying to show the number of lines, words and characters of all configuration files in /etc/*conf (with command wc). How can I modify the command (or commandline) to not view the error messages?
1
vote
1answer
17 views

ps aux status column meaning?

On a Mac, 64 bit, osx 10.8.5, two of my ps aux output lines, plus the header, are ; $ ps aux | head USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND myuid ...
1
vote
1answer
19 views

Is there an event fired right after a command finishes executing?

In Bash, after you type in a command (e.g., ls), it will execute the command, which will write its standard output (if not redirected) to the terminal (in our example, the content of the current ...
3
votes
2answers
671 views

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

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 ...
2
votes
2answers
2k views

rm - command not found

I recently wanted to use the rm command in Terminal on my Mac. To my surprise, it just reponds with: -bash: rm: command not found I can use mv, cp, cd, ls etc. However rm somehow doesn't work. I ...
8
votes
8answers
4k views

Pushing my PS1 prompt over ssh

I use a specific PS1 prompt that I like. I share a few logins with other other people on a few different servers. I was wondering if there was a way to specify in my local bash profile a remote prompt ...
0
votes
2answers
318 views

vnstat: print current network activity to a file

How can i print the output of vnstat -l to a file? what i've tried: vnstat -l &> file but it just hangsup
1
vote
2answers
344 views

Format data as a table in bash

I have an array of JSON data being printed to the terminal (OS X) and I want the properties of that to be displayed in a table in the terminal. Sample query: aws ec2 describe-instances | jq '[ ...
2
votes
3answers
97 views

How to open one GNU screen tab for each directory in a list

I have the following script - it sort of works. #!/bin/bash ... define plugins, etc for plugin in ${plugins[@]}; do screen -t $plugin done Want I want it to do open gnu-screen and for ...
0
votes
3answers
45 views

How Can I Batch Change the Metadata of MP3 Files? [duplicate]

I have a fews of songs in a folder which I would like to add the metadata items of artist, title, genre and album to. I would like to take the metadata info for the title and artist from the file name ...
0
votes
1answer
19 views

How to compare those (date) values in bash

I need to compare 2 strings of the following formatting: 2013-12-31T00:00:00 2014-11-19T15:40:30 Its a custom datetime format. I tried different things, none worked: if [ ${val1} < ${val2} ] || ...
0
votes
1answer
59 views

How to restore virtual host configuration on Mac OSX

I successfully created some virtual hosts on my machine a while ago by modifying my /etc/hosts file and my http-vhosts.conf file. Then I found a very handy tool called virtualhost.sh ...
8
votes
2answers
6k views

When to use egrep instead of grep?

I am preparing for a Linux terminal assessment now, I tried to Google and found most resources are referring to the basic "grep" rather than the more powerful "egrep" -- well, that is at least what ...
1
vote
1answer
552 views

What is wrong in the Bash script about parameters and Wget?

Runnning the command gives wget_exam -h Usage: wget_exam2 <fileType> <source> exit // then immediately Terminal shut dows The code # example wget_exam2 java ...
0
votes
2answers
20 views

Bash Process output status

I would like to ask about creating new processes in bash script. I have script which will execute external programs tests and then check its output status and print if test was successful or not. ...
4
votes
1answer
653 views

sudo -E not passing all variables

Reading the man pages I expected sudo -E to pass all environment variables to the subshell, but I am not getting the expected results. As expected, awesome: $ export ...
4
votes
4answers
5k views

Setting ID3 title tag to be equal to MP3 file name

Has anyone got a bash script that will go through a media library and set the id3 title tag of each MP3 file to be equal to the file's name? I'm open to other automated methods too. It can be a GUI ...
3
votes
1answer
43 views

How can I check if timezone has changed in a bash script?

I have a shell script that runs via crontab, but the commands in it are timezone dependent (they refresh a table in database everyday. If the script runs during the time of a DST change, it will ...
0
votes
1answer
27 views

Damaged preference file in /bin/sh

Today in Drive Genius 3, I ran the “Verify Preferences” function in Repair. It yielded this strange result: /bin/sh: xargs: command not found The only option Drive Genius gives is to remove the ...
3
votes
1answer
219 views

Bash: detect execute vs source in a script?

I have a script that is littered around my filesystem (side effect of a build process) that sets some global environment variables (LD_LIBRARY_PATH, PATH, ROOTDIR, etc) that need to be in my shell for ...
1
vote
3answers
3k views

Using egrep to find lines that have 5-6 Upper Case letters. (but not more than 6)

First off, this is homework and unfortunately I have to use egrep (and not with -w or anything of the like). I need my grep to return lines that have exactly 5 or 6 upper case letters. Doing ...
2
votes
4answers
1k views

How to grep for a line that has the same number you both need and don't need

This isn't at all easy to explain but easy to just show. I have lines in a file such as: 100Dollars 3 IP 200Dollars 3 IP 300Dollars ...
1
vote
1answer
29 views

Want to create custom command and be able to pass arguments to it

So I have following command which I using pretty often on server ps aux | grep someword | awk '{print $2}' | xargs kill -9 What I want is make alias to this command and be able to pass arguments to ...
1
vote
1answer
470 views

Find duplicate file use cmp command

I would to write a bash script to find duplicate files but I don't want just use md5sum. It means, in addition to use md5sum I want to check my files with cmp command. I use the command below for ...
0
votes
1answer
192 views

How to write a script that does what less does?

Question: Create a script such that it is a command that has the same effect as the "less" command (implement the script by calling "less"). What I wrote: #! /bin/bash for index in "$@" do less ...
-2
votes
1answer
37 views

Bash executing command

Can anyone please give me the list generated by this : -{ for i in {1..100}; do lynx -dump -nonumbers -listonly [http]://www.dailymotion.com/user/MTDCafe/$i ...
2
votes
1answer
48 views

Dynamic variable substitution in PATH

I want to run different versions of Java on the same machine (Linux Mint 17) with default to Java 7. So I put this into /etc/environment: JAVA_HOME="/tools/java/java7" JAVA7_HOME="/tools/java/java7" ...
1
vote
5answers
5k views

How do I substitute environment variables when I ouput a file?

I'd like to somehow spit out a file (which has env variable references) and substitute the actual values. This is what I've tried, but as you can see it's not working. Any ideas? -bash-3.00$ cat ...
0
votes
0answers
35 views

Alternative ways of passing PS1 env variable into Ubuntu for SSH session

I know that there are twenty thousand answers, none of them worked as expected, I'm more surprised than you are, so please consider reading the story first. I'm trying to achieve what appears to be a ...
0
votes
1answer
28 views

Open file using bash with unix executable

I have an application which loads using a bash script e.g /Applications/My.app/Contents/MyExecutable I can load this using bash like so "/Applications/My.app/Contents/MyExecutable" However, I ...
1
vote
2answers
49 views

Status line in linux shell

I use Windows and Putty in order to remotely connect (ssh) to some linux servers. I have set my hardstatus in my .screenrc file so that I can monitor some useful information. But this works only when ...
2
votes
3answers
3k views

sha1sum for a directory of directories

sha1sum ./path/to/directory/* | sha1sum the above was posted as a way to compute a sha1sum of a directory which contains files. This command fails if the directory includes more directories. Is ...
0
votes
1answer
39 views

Delete All files except specific file in bash [duplicate]

I am trying to use rm -rf !(current) delete all folders in current path except current folder. But I am getting below error bash: !: event not found How do I get this functionality in bash?
1
vote
0answers
41 views

PuttyCyg not starting correctly: “Must be connected to a terminal” error message

My computer is running Windows 7 SP1 64 bits with CygWin 64 bits installed and updated (as for 16-Nov-2014). I need to run the screen program of CygWin in a text console. I am trying PuttyCyg, a ...
1
vote
1answer
19 views

How to detect from a shellscript that a file on remote server has changed?

What could be used to detect that remote file is different compared to a local file? Possibly using ssh as a channel for communication. Scripted in bash, having linux servers in mind. This could be ...
1
vote
2answers
30 views

Shortcut to execute output of last command in Linux

Is there any shortcut to execute the output of the previous command, such as executing whatever is found by the locate command? For instance, if I run this locate command and get this output... ...
2
votes
1answer
45 views

In bash 4.3.27 “su” ignores user variables when combining “-” with “-c command”?

Since forever we used to launch user scripts from a different user crontab like this: 00 12 * * 1 su - user2 -c "/home/user2/myscript.sh" By doing this, the script is launched after the interactive ...
5
votes
1answer
725 views

How to continue scp transfer from last file

I was transferring large files using scp, but I got this error: write failed: Broken pipe lost connection. Now I need to re-launch scp but tell it to continue from where it left off. I looked into ...
56
votes
6answers
18k views

What is the difference between executing a bash script and sourcing a bash script?

What is the difference between executing a bash script like A and sourcing a bash script like B? A >./myscript B >source myscript
0
votes
1answer
22 views

Difference between su and su -c (environment variables?) when running db2?

When I type this: su <user> -c "/home/<user>/sqllib/bin/db2 catalog tcpip node <dbName> remote <ip> server <port>" I get this error message: SQL10007N Message "-1390" ...
2
votes
1answer
56 views

How to change BASH “editing-mode vi” shortcuts?

I'm trying to change my bash vi mode keys to enter and exit insert mode, I would like to set these shortcuts: Ctrl-\ : Enter moviment mode Alt-\ : Enter insert mode how can I do that? I'm trying ...
0
votes
1answer
73 views

Brew & Ruby no longer functioning properly due to a recursive trap

After updating to OS X 10.10 (Though this might have been irrelevant), I was not able to run any brew commands. Any command gave me this error: /usr/local/bin/brew: /usr/local/Library/brew.rb: ...
1
vote
2answers
132 views

How to make a bash script wait and then continue running?

I have an .sh script. I would like to wait 25 minutes and then continue running, NOT repeat. It's something like this: #!/bin/bash /bin/bash ~/path/script.sh I want it to kill a process after ...
1
vote
1answer
23 views

Search for string and read the next line

I need to write a shell program that installs some packages. The program will run on Linux (obviously some commands will not work, for example, on Arch-based distros). So, I've got this file called ...
0
votes
0answers
10 views

rename using perl eval can mmv do this

Linux Mint 17 64-bit The following works to rename the numbering of files. # rename -n 's/(\d+)(.*)/($1+99).$2/e' *.txt 1-file.txt renamed as 100-file.txt 3-file.txt renamed as 102-file.txt ...
0
votes
0answers
19 views

Can I use ProxyCommand to run arbitrary commands on a target server via a jumpbox/middle server?

At work, we have a number of servers that we can only SSH into from our jumpbox server. Every now and then I need to execute a command on these servers. For example, if I want to execute df -H on ...
0
votes
1answer
34 views

Connect to PgSQL, DROP existent DB, recreate it using CREATE and run some queries alone and from files using Bash script

I need some advice creating a script for help me with repetitive task I do all the time on a development environment. I've a PostgreSQL server and since I'm developing a web application I need to ...
1
vote
1answer
38 views

Format terminal output to show apt-get upgrade errors in RED

I have a VERY simple bash script written for my Kali Linux distro so I don't have to run apt-get update, apt-get upgrade, apt-get dist-upgrade, apt-get autoclean, and apt-get autoremove every time I ...
0
votes
1answer
4k views

Timezone conversion in Bash script

I found a solution about how to convert time zone with the Linux date command: Timezone conversion by command line $ date --date='TZ="Asia/Taipei" 18:00' Fri Jul 16 11:00:00 BST 2010 It's working ...
1
vote
2answers
111 views

Monitoring Excessive User Home Directory Growth

I am trying to write a script for a school assignment that will check and see if any of the non-administrative user home directories have increased in size by more than 100 MB in a single 20 minute ...