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

learn more… | top users | synonyms

10
votes
2answers
586 views

What does a bare < do?

bash does not seem to complain if you run a command like $ < some-file-that-exists Nothing seems to happen. You could also use $ <<<"any string" and even process substitution. So ...
4
votes
3answers
675 views

Diff 2 files while ignoring parts of lines

I would like to diff a file system. Currently my bash script prints out the file system recursively into a file (ls -l -R) and diffs it with an expected output. An example for a line in this file ...
1
vote
4answers
573 views

How can I clean up my bashrc/zshrc file?

Over time, I've added bunches of stuff to my PATH and it's lookin' pretty awful. How can I clean this up or what's the proper way to "reformat" all of this? export PATH="$PATH:~/scripts" export ...
4
votes
5answers
2k views

What is the purpose of the `sh` command?

What is the purpose of the sh command when used interactively and when used inside of a bash script? Other than on the hash bang line (the first line) should sh ever be replaced with bash on a bash ...
1
vote
1answer
1k views

Is it possible to get user's input during installation of rpm?

Is it possible to get input from a user during an rpm installation? I have a script that works by itself (taking input from a user and doing actions) but when run as part of the post install of an rpm ...
3
votes
5answers
162 views

BASH: Adding existing filecontent to an existing file

I've to add the content of a file to the end of every prefs.js file. Tried it with find -name 'prefs.js' -exec more filecontent >> '{}' \; but it didn't work.
6
votes
3answers
557 views

Use msysgit/“Git for Windows” to navigate Windows shortcuts?

I use msysgit on Windows to use git, but I often want to navigate through a Windows-style *.lnk shortcut. I typically manage my file structure through Windows' explorer, so using a different type of ...
6
votes
2answers
893 views

What is the full name of rc file? e.g. bashrc? [duplicate]

Possible Duplicate: Sayvimrcor screenrc, what does the rc mean? There are lots of rc file inside linux? .bashrc .vimrc .gvimrc etc etc I am curious what does rc mean? I can't find any ...
1
vote
2answers
55 views

nasty process hogging my shell

While for most of the processes started from shell I can grab my shell back from them with a sequence of Ctrl-z and bg, it seems that some won't allow me back in control in the case of, e.g., mysqld. ...
6
votes
5answers
1k views

delete or rename a file with \r as the file name

I have a pesky little file whose name appears to be single character, and that character is a \r How can I delete this? This is what I get with ls -bl: -rw-rwxr--+ 1 root ...
0
votes
1answer
68 views

basic bash console mac

I am very inexperienced with the console, I have been exploring rails and somehow my command root in the console used to be: Ross-MacBook-Pro:....$ inadvertently it has now been changed to: ...
1
vote
1answer
80 views

What `find` command deletes everything in a directory except for CVS folders?

I have a dir: $ tree . |-- CVS | |-- Entries | |-- Entries.Log | |-- Repository | `-- Root |-- dirA | |-- CVS | | |-- Entries | | |-- Repository | | `-- Root | |-- file1 | ...
0
votes
1answer
105 views

What do I need to run to undo an alias a bash script made?

I usually use the mamp server on my Mac, but yesterday I ran this script. #!/bin/bash WWW_BASE='/Library/WebServer/Documents' TARGET="$WWW_BASE" expand_dir () { pushd "$1" >/dev/null ...
2
votes
2answers
2k views

A Unix shell command alternative to echo

I'm trying to output string literals to a file. So far I've been trying to use the echo command, but unfortunately I've discovered it's impossible to output '-n', '-e' or '-E' (at least not without ...
0
votes
2answers
3k views

change from bash shell prompt to regular shell prompt on centos

my centos environment has just become bash shell prompt: -bash-3.2# how do I change it back to the usual # prompt? what places should I check for possibly modifications? Update: I was not clear ...
2
votes
2answers
91 views

cryptic bash variable

I encountered this cryptic bit of code which I believe contains some form of variable expansion. echo "Usage: ${0##*/} [-f] [-u user] [--] " Is the dollar sign followed by the brace-enclosed string ...
2
votes
2answers
887 views

Bash alias with piping

I'm not exactly sure what I'm doing wrong with this one. I'm trying to run the command alias localip='ip -4 -o addr show eth0 | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}' | head -n 1' If I ...
0
votes
1answer
155 views

MinGW interactive shell?

I see that MinGW shell launches with sh --login -i Another way to launch would be like this sh --login I know that -i is for interactive shell, but I am not seeing a difference between the two ...
2
votes
1answer
466 views

Bash script to run a clamscan on Ubuntu- how to use return values properly?

I'm trying to put together a simple script that will scan my home directory with clamscan and give me a warning if any viruses were found. What I have so far is: #! /usr/bin/env bash clamscan -l ...
0
votes
2answers
113 views

Script that deletes a directory but doesn't delete marker files on linux

I got a script running and its cool and all. Any idea how to make this script run under just 1 level of subdirectory? #! /bin/bash #This will delete the sub-directories of a specific directory when ...
1
vote
1answer
365 views

Simulate pgrep using plain grep

How can I do pgrep -U someUserName using just ps and grep? I.e. not count on pgrep being set in a system?
0
votes
2answers
3k views

Get the process id from ps -ef grep (or Stop an application before removing it)

I have an rpm and I want on uninstall to check if my application is running and if it is stop it before running the uninstall. My service runs under a specific user. How can I do this using bash in ...
2
votes
1answer
455 views

Generate a list of files by piping output of find command into another find command?

I need to generate a list of files for use in a shell script. The list should be all files (in a specified directory) that are hardlinked. I want to replace the hardlinks with symlinks. (Obviously, ...
2
votes
0answers
394 views

How to mount SMB share from terminal using keychain?

I need to be able mount a SMB share from terminal, for MAC OS versions (10.7). Is there a way to use mount_smbfs with keychain so I don't get prompt the username/password or have to add it to the ...
0
votes
2answers
380 views

Loop through string with non-standard EOL delimiter

I'm trying to loop on the output of a command which spits out lines delimited with \n instead of the bash internal field separator. I have a workaround which temporarily changes the IFS to \n: ...
0
votes
1answer
294 views

ls link count seems incorrect - how do I ensure I'm not deleting the inode contents?

ls -lai on a file gives me a link count of 2: 16508 -rw-rw-rw- 2 ... Then looking for all the filenames returns only one: find "$dir" -inum 16508 This lists only the original file, not two. ...
0
votes
1answer
387 views

Replace text with text from another file in a script?

I want to replace 5 rows of text in a file with the text of another file in my script, I know that running vim I can do :45,50d :r replacement.txt to delete 5 rows and then insert the entire file, ...
0
votes
1answer
123 views

How to find files, print some standard info about those files, plus print the alpha char count of each filename?

I want something like this: find "$dir" -type f -printf '%i:<alpha_char_count_of_base_filename>:%d:%p\n' Then I want to sort first on inode number, then on alpha_char_count_of_base_filename. ...
3
votes
1answer
425 views

Bash: how to enter a subdirectory that's most recently modified?

I know I can find a directory that's most recently modified by doing ls -ltr, but the last modified item might be a file, not a directory. Secondly I still have to type the directory name. My ...
0
votes
1answer
248 views

How to improve this bash shell script for turning hardlinks into symlinks?

This shell script is mostly the work of other people. It has gone through several iterations, and I have tweaked it slightly while also trying to fully understand how it works. I think I understand it ...
1
vote
3answers
521 views

Background job in bash is shutting down when the firing window is closed: how to avoid this?

You can go quickly to the question starting reading from 'Having said that' The following are details on my specific needs I'm on lubuntu oneiric and trying to create a desktop launcher to start / ...
0
votes
0answers
223 views

bash script rm cannot delete folder created by php mkdir

I cannot delete folder created by php mkdir for I in `echo $*` do find $I -type f -name "sess_*" -exec rm -f {} \; find $I -type f -name "*.bak" -exec rm -f {} \; find $I -type f -name ...
1
vote
1answer
171 views

Is there a shell script that helps identify the non-system related files to backup?

Is there an application or script that will identify all of the distribution/system files? My ultimate goal is: I would like to automate backups to a secondary/alt sec Linux machine, but I would like ...
1
vote
1answer
785 views

Output high CPU processes using bash shell

I am trying to monitor my CentOS processes using top command to see if there are any processes where CPU usage is greater than X%, below is the command I am using to see if any processes CPU usage is ...
2
votes
1answer
466 views

linux/bash conditional syntax on command line

I want to run foo if and only if the current day of the month is less than the 7th. So something like: [ (/bin/date +'%-d') -le 7 ] && foo Except that gives me a syntax error. The date part ...
1
vote
2answers
565 views

What bash < < syntax mean?

Ruby Version Manager (RVM) installed like so: bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) I understand what first < mean (feeds bash ...
3
votes
4answers
1k views

Chmod equivalence of +x and 0755

Just curious, are these two completely equivalent? chmod +x file chmod 0755 file Thanks :-)
11
votes
1answer
8k views

Rename user's group name

I just did usermod -l login-name old-name to change the username, but the group name is still the old one. Any way of renaming the group name? I can't find any info to do so.
0
votes
2answers
371 views

How can I make Bash (or Zsh) run a particular command before each entered command?

I'd like to configure Bash to run a particular command before running each command line I enter at the prompt. Specifically, I'd like to tell Vim (which is running in another terminal) to write all ...
1
vote
2answers
548 views

How to list directories names but not their contents, in *N*X?

If I do a simple ls specifying a filename pattern, like ls A*, for directories that match the pattern, it will enter the directory and give the full listing, but how could I get just the listing for ...
17
votes
2answers
3k views

How can I make the bash backtick operator keep newlines in output?

Is there a way to make bash not eat newlines in the backtick substitution? For example: var=`echo line one && echo line two` echo $var line one line two What I want is var=`echo line one ...
0
votes
1answer
111 views

Where are variables sourced from in bash/redhat?

I am getitng something weird in my environment. I have a .bash_profile that only checks for .bashrc and then sources it. I have a JAVA_HOME in that file that is correctly setting the variable and ...
0
votes
4answers
4k views

How to pass bash script arguments to a subshell

I have a wrapper script that does some work and then passes the original parameters on to another tool: #!/bin/bash # ... other_tool -a -b "$@" This works fine, unless the "other tool" is run in a ...
3
votes
1answer
425 views

Print only attributes of file in linux

Is there a way to print only the attributes (size in particular) of a file without showing the filename? file -b * is similar to what I want, but . Maybe there is way of combining ls -hs and file -b?
6
votes
2answers
4k views

How to redirect to stdin of a running bash shell?

Theoreticly, if I know the pid of the bash shell which is running, I can run a cat whose stdout is redirected to the stdin of that shell. It seems to be as if I type something on that shell. ...
0
votes
1answer
508 views

How do I get zsh's autocomplete to complete wildcards like bash does?

In zsh and in bash, if I type ls c<TAB> it displays every filename starting with c. If instead I type ls c*<TAB>, bash behaves the same way, but zsh replaces the c* with the list of every ...
3
votes
2answers
286 views

Wrong linebreak on SSH connection when scrolling back in bash

I have a Bash Terminal via a SSH connection in GNOME terminal. Server is Debian Linux, Client is Ubuntu Linux. The output of long lines is displayed well, but when I use the UP-key to scroll in the ...
0
votes
2answers
1k views

Ubuntu terminal: “No such file or directory” [closed]

I am using Ubuntu 11.10 and get the following error when using the terminal: lee@theia:~$ regedit/home/lee/desktop/Direct3D.reg bash: regedit/home/lee/desktop/Direct3D.reg: No such file or directory ...
2
votes
1answer
2k views

unexpected EOF while looking for matching `''

Could anyone explain to me why echo 'test \'hi\'' > test doesn't work? It doens't write hi to the file test. The single quotes seem to be properly escaped, aren't they? Thanks.
2
votes
2answers
458 views

Git completion __git_ps1 really slow on Mac

I've had __git_ps1 in my bash prompt for a while, but just recently (I noticed it after I did some messing around with Homebrew and rbenv), it has slowed down my prompt horribly. When I'm in a git ...