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

learn more… | top users | synonyms

2
votes
3answers
382 views

osx: selectively zip large number of files: -@ option OK?

I need to make a zip file archiving ~100k files from a directory containing ~500k files. I get "argument list too long" errors when I try the obvious commands: zip archive.zip *pattern*.txt ...
3
votes
1answer
2k views

How to select text in terminal? (linux mint)

I tried Ctrl+a and the cursor changes but what do I have to press afterwards? ( tried Arrow keys and Alt+Arrow keys and Shift+Arrow keys and so on)
2
votes
2answers
334 views

Bash Fastest Way to Rewrite Screen

I am using bash on Mac OS X as well as Lubuntu. One of the annoying things about when I make console applications is that clear will add a whole (x-number) of lines to the console. And then I ...
1
vote
4answers
2k views

How to combine find and grep to recursively search for str or str2 in *.html and *.php files from /home/smith/sourcecode?

How can i combine find and grep to search for str1 or str2, recursively, in all *.html and *.php files starting from a directory named /home/smith/source? The output only needs to list files (with ...
2
votes
1answer
58 views

How can I create several folders?

How can I create several subfolders in folder in one command. For example, I want to create: /home/user/*create dir1*/*create dir2*/*create dir3*/ Provided, I don't have dir1. And I can't use 3 ...
0
votes
1answer
69 views

Script or approach to “update” several files from directory1 to directory2 under Linux

I have two directories, directory1 and directory2. What is the cleanest way with a linux friendly script that would copy the latest files from directory1 onto directory2 including the same sub ...
1
vote
2answers
87 views

unix command zip everything except file ending with _fpartxx

I was wondering, if I have a folder structure like this: /var/www/testing/file1.iso_fpart0 /var/www/testing/file1.iso_fpart1 /var/www/testing/file1.iso_fpart2 /var/www/testing/file1.iso ...
2
votes
1answer
304 views

Enabling Bold and Color with LPT parallel printer

I know how to echo text to my HP Deskjet 420 printer on lubuntu with bash: echo -e "line of text" > /dev/lp0 Is there a way to print text that is bold or in color? Should I echo some sort of ...
2
votes
2answers
65 views

What file is CTRL+R searching in Debian?

With CTRL + R we can search in previous commands (in the terminal of Debian). I always assumed it was searching my .bash_history, but that doesn't seem to be the case -- right now my .bash_history is ...
0
votes
1answer
78 views

LPT Printer Indents Text When Printed

I originally posted this at Stack Overflow but I thought it would be more appropriate here: My LPT? printer (HP Deskjet 420) is indenting text when I print to it: echo -e "this is text" > ...
1
vote
2answers
7k views

sudo to run command as different user

I am trying to setup a script that will be run as a "maint" user. The script is basically a menu that allows maintenance personnel to do different things on the server. However, some of the scripts ...
1
vote
3answers
1k views

How to grep long string across multiple lines, without knowing where the newline is

I want to search for a specific string across multiple lines in a file and get the line in which the match was found. However, my problem is, that the file contains one very long string, and not, ...
1
vote
2answers
525 views

Bash script executes but 'until' command not found

I'm writing a bash script for a class that has a main menu with two submenus. I haven't finished my script yet, but I already have a problem I haven't been able to remedy: My script runs fine but ...
1
vote
1answer
152 views

terminal (bash) run program on other machine without copying it across

Is there a way (using the terminal - bash) I can run a program using someone else's processor, ram , monitor, speakers, etc but have the program stored on my machine? To explain: Now I have a java ...
2
votes
1answer
594 views

SSH not reading rc files

Once upon a time, an ssh invocation to host1 like ssh u@host1 command would read .bashrc before executing command. host2 is administered by the same people, and reads .bashrc! I don't administer ...
1
vote
2answers
170 views

Bash script - find directory, and do something in it. Or find a file, and do something with it

This is what I have so far: for f in 'svn ls repository_dir'; do svn checkout repository_dir/$f/trunk/dir1/dir2/dir3/dir4/needed_dir done This works great for the projects (100's of them) that ...
-1
votes
1answer
178 views

Bash variable in {$var} brackets reads as %7Bvar%7D?

I am trying to do a for loop, but Cygwin does not understand the {$var} syntax. My command: for f in 'svn ls repo_path'; path/{$f}trunk/path; done Error svn: E170000: URL path/%7Bvar%7Dtrunk/path ...
1
vote
1answer
1k views

How do I append a bunch of .wav files while retaining (not-zero-padded) numeric ordering?

I have many (7500) .wav files (named by their numbers) which I'd like to merge into one. I think it has to be done with a bash loop because with using globbing some files would be in the wrong order ...
3
votes
0answers
19 views

How do I skip the requirement to hit tab twice on a soft link autocomplete? [duplicate]

When I am in the bash terminal (Mac) and I am selecting a file, I can easily type the first part of a directory and hit tab to have it auto complete, for example: cat ~/Desk [tab] -> cat ...
1
vote
2answers
266 views

Delete users who havent logged in for x days

got the simple code below USERS=`cat /etc/passwd` for USER in $USERS do echo "---------- $USER --------------" last -n 4 $USER done I want to ideally remove all users who haven't logged in ...
6
votes
3answers
2k views

ffmpeg/avconv force scaled output to be divisible by 2

I record my desktop with avconv (aka ffmpeg) and then scale it to 720p. I recently added to my script so they can select a window with xwininfo and it will record that one specifically. However, if ...
2
votes
1answer
134 views

How to get the result from bash auto-completion as a string?

What I'm looking for is not how to add autcompletion in bash for another program, but a way to get the result of what would have happened in bash to a string, basically: autocomplete "/etc/apa" ...
1
vote
2answers
559 views

Finding not empty directories without subdirectories and specific sorting

I have a problem with my "homework" on studies. I have to list all not empty directories from /var and /usr, which do not have subdirectories and their owner is not root user. Also, for each ...
0
votes
2answers
108 views

Default text for the shell read command?

Basically I want default input that the user can edit if necessary. Eg: Please enter the city: Toronto where "Toronto" is the default text and the user can actually delete it and enter another ...
0
votes
1answer
204 views

Upgrading PostgreSQL via Homebrew

I'm attempting to update PostgreSQL from my system's version (9.1.5) to the latest release (9.2.3). I've followed the directions on this railscast and am encountering issues. After installing psql ...
2
votes
2answers
588 views

Redirecting shell command outputs to another konsole shell

I am writing a shell script and I would like to write commands in the script but redirect the output to other konsole sessions. (using kde)
2
votes
1answer
524 views

environment using su - vs “ssh user@machine” as a user on lucid

I'm trying to debug a shell environment issue on a machine running lucid. Both root & user have /bin/bash as their shell in /etc/passwd When I use "sudo su - user", my PATH includes the following ...
2
votes
3answers
1k views

Source new .bashrc in all open terminals

I find myself having many terminals open at once all the time. When I update my .bashrc, I have to go to each terminal and execute . .bashrc to source the terminal with the new .bashrc. This is ...
1
vote
2answers
90 views

Finding folders only

My harddrive is in a mess, so I decided to do a cleanup. As a part of this, I want to merge all folders containing music into one. What I want to do is, look for any *.mp3's and *.aac's on my drive ...
1
vote
1answer
522 views

awk - max value of a rolling average

I have a bash command which gives me the highest value in the 9th column of a file: cat "log.txt" | grep 1923 | awk '{print $9}' | sort -n | tail -1 log.txt is a log of CPU usage for process 1923 ...
1
vote
3answers
868 views

How do I handle the failure of a command in a bash function?

I have a bash function on one of our test servers that deploys our code, but one of the commands fails frequently and we can't find the cause. We just retry until it works. I want to have the ...
1
vote
2answers
729 views

Function defined in my user's .bashrc causes an error when I sudo su

I have a function defined in my user's .bashrc file that displays my current git branch name at my command prompt: parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* ...
0
votes
2answers
331 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
1answer
122 views

Bash readline move cursor to previous forward slash

In bash , we can move back or forward by 1 word or character. Is there any option where i can move the cursor to the previous character that i specify, for example Forward Slash. ? Something like the ...
2
votes
1answer
2k views

How to split the HTTP error code from the contents in cURL?

Yes, this is related to Getting curl to output HTTP status code? but unfortunately not the same. In a script I would like to run: curl -qSfsw %{http_code} URL where the -f option ensures that the ...
0
votes
1answer
1k views

UNIX command to sort the file by the following words, from major sort key to minor sort key: word 3, word 1, word 4

Need help with the UNIX command below to sort the file by the following words, from major sort key to minor sort key: word 3, word 1, word 4. (words are separated by white spaces) sort -t -k3 -k1 ...
1
vote
1answer
71 views

Bash process substitution

I can figure out why the following process substitution doesn't work: kompare <( echo one two ) <( echo three four ) Kompare opens, but says that the input files are identical.
2
votes
3answers
130 views

save password once and use it from different terminal

I have script that runs remote login using SSH, copies a file from that remote machine using SCP without asking for a password, however, the change only works for the terminal where I am running the ...
2
votes
1answer
581 views

How to ack-grep replace a string of multiple words

The following command replaces every occurence of the word from in any file of the current directory or its subdirectories with to: ack-grep -l --print0 --text from | xargs -0 -n 1 sed -i -e ...
3
votes
3answers
5k views

How to get only the user, the pid and the command run for a specific process? (Ubuntu 11.10)

When I do ps -ef|grep python I get the following: myusername 4492 2994 0 10:32 pts/0 00:00:01 /home/myusername/.virtualenvs/myproject/bin/ipython manage.py runserver root 6665 1 0 ...
0
votes
1answer
112 views

Pmset multiple repeating schedule pairs

Can the pmset bash command be used with more than one repeating action pair? For example: Wake or Power on at 13:00, Sleep at 17:00 and Wake at 18:00, Shutdown at 20:00 If not, is there an ...
1
vote
1answer
80 views

Why does this not work? echo 'abc' | strings

I found tcpdump -l -s0 -w - tcp dst port 80 | strings on this article. So I want to try to use strings command. But command like echo 'abc' | strings does not work. Why? Thanks in advance. I ...
0
votes
2answers
697 views

is it possible to install software without asking for a password?

Okay, so i am not sure if it is possible, but i am creating a menu and the user can select an option that will install two bits of software, however, once this is pressed there can be no other ...
1
vote
1answer
326 views

ps comm format always cuts the process name

I am trying to invoke ps -o comm:1024 --pid 1391 --cols 1024 -w in the hope of getting the full process name (and only that), but I always end up with this COMMAND notification-ar while the process ...
0
votes
3answers
95 views

How to run a script I wrote like a command?

I have a shell file, for example wd.sh and I want to turn this into a command called wd that I can run without having to sh it, just like running cat, sort, or any other UNIX command. How do I do ...
3
votes
1answer
592 views

how to extend bash history in Linux Mint 13?

How do I increase the command history size in Linux Mint 13? There is no ~./bash_profile in Linux Mint 13 and changing ~/.profile to include something like HISTSIZE=4050 HISTFILESIZE=4050 Did ...
0
votes
1answer
216 views

cp - copying and keeping different version

How to copy all .aze files that have different contents into folder3 ? The screen show what I don't want to do. What I want to get close is to have in folder 3, file1(1).aze and file1(2).aze (and ...
6
votes
3answers
6k views

shell scripting - How to zip contents inside a folder without the folder itself?

I use this current command that archives the folder "folder-root" and all it's content to a file named "site.zip": zip -r site.zip folder-root/* Problem is - I want to zip the contents of the ...
2
votes
2answers
154 views

Unable to get profile variable using ssh

Unable to retrieve the profile variable using ssh. server2 ==> user apptst ==> bash profile has $APPHOME variable. Was trying to retrieve the value from server1 using ssh but failed. Used options ...
0
votes
2answers
144 views

How to deal with the shell input before it executed in Bash or zsh? [closed]

everyone. I am a bash/zsh user(Linux). I want to realize the following things. First, input the command in the bash/zsh shell, like: $ wonderful: In fact, a program named `wonderful:' doesn't ...