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

learn more… | top users | synonyms

2
votes
1answer
186 views

After updating bashrc in cygwin the cursor starts at column 0 instead of after the prompt

The issue is that, if I update PS1 in bashrc, I see that by default the cursor gets placed at column 0 instead of after the prompt, and if I type anything it starts overwriting the prompt. I tested ...
2
votes
5answers
779 views

How to insert the last output line into the command line?

Does bash provide a way to insert the last output line of the previous command into the command line? For example, suppose I just ran ls -1 and the output was file1 file2 file3 Is there a key ...
3
votes
1answer
417 views

How can I graph memory usage by user?

Basically, I want to graph the memory usage with each username as title, as time passes by. I would set that script as a cron job, to create a graph that shows memory usage of certain usernames. How ...
0
votes
0answers
607 views

find and replace in PDF using sed and pdftk

I am doing a mass find and replace using sed and pdftk to find and replace a word in PDF files. When I run the following command, sed -e "s/word1/word2/g" test.pdf I get the following error, sed: ...
2
votes
2answers
436 views

Recursively zip files into .cbz-files based on folder in command line

I'm trying to figure out how to write a script to automate creating .cbz files from images in folders on OSX. My directory tree will look like this: /toplevel/ cbz/ comics/ Comic1/ ...
0
votes
3answers
371 views

Write pipe result to variable

I need to be able to write whether the test for a grep is either TRUE or FALSE to a variable so I can use it later For the following, if I run defaults read com.apple.Finder | grep ...
0
votes
2answers
737 views

How to organize files in accordingly named directories from command line under Linux

I have a directory filled with various files, differently named (i.e. not named with a specific pattern) and with different extensions, and I want to put each file in a newly created subdirectory ...
0
votes
2answers
118 views

Bash script with OR condition

Hoping someone here can help me with a bash script that runs only on certain conditions. #!/bin/bash TODAY=`date +%Y-%m-%d` MODE=$1 if [ $(date '+%A') == "Sunday" ] || [ $(date '+%d') == "01" ] || [ ...
0
votes
2answers
157 views

Make directories for each file placed in main directory [duplicate]

I want to place a list of files into individual directories I create from each filename. So given the files in the root directory: Movie1.avi movie2.m4v movie3.mp4 I want to mkdir Movie1, movie2, ...
0
votes
1answer
83 views

bash terminal: can the find and make duplicate text be extended globally--Apple?

From Finding and removing duplicate files in osx with a script, can this be extended to find duplicates across the whole hard drive instead of per folder? I know there are duplicates but they aren't ...
1
vote
0answers
62 views

Running a symlink locally

I am running the same program multiple times over a linux platform. It is compiled at another server, and frequently updated, and it's uploaded over through rsync to all "hosting" servers, which do ...
0
votes
4answers
301 views

bash - directories ending in . and whitespace cannot be removed

On my external hard drive are two directories, Fun. and Complex_, where that _ is a whitespace. I cannot empty from my trash or remove them with rm -rf and I want to. Neither show up in Finder on ...
0
votes
1answer
292 views

Find files containing text in the name and move saving permissions to another folder

I've got asterisk srecords in mp3 format with naming like 13-07-31__09-32_205_988007007757.mp3 in /etc/asterisk/record I need to select files, containing, for example *_205_* and move them to folder ...
1
vote
3answers
478 views

Ignore NTUSER.DAT files when ls on Git Bash?

I use Git Bash as my terminal on Windows. When I ls in my Home directory, I see some NTUSER.DAT entries, which I assume are system files. They don't appear when I run dir in the default Windows ...
0
votes
1answer
914 views

useradd denies home directory creation Ubuntu 13.04

I'm trying to set up a git user, but am getting the error useradd: cannot create directory /srv/data/git when running this command sudo useradd \ --create-home ...
3
votes
2answers
153 views

useful or useless use of cat in input

In my mysql restore script I use a mysqldump file previously created for input. This filename is provided on the command line as an argument and may or may not be gzipped. I want to use the file as ...
0
votes
1answer
158 views

Can you repeat last command with flags in bash?

Is there a way to repeat your last command with additional flags? Example: Say I do this: rm myFavouriteDirectory I will get a reply: rm: myFavouriteDirectory/: is a directory Obviously what I ...
1
vote
4answers
629 views

Clear terminal output of last command only

Rather than scroll past hundreds of lines of output to see the previous command history, can the output of the last command be cleared? E.g. after executing ls, clear its output because you don't ...
0
votes
1answer
374 views

“history position out of range” when calling history from bash script

I want to make a simple script to delete a line from bash_history, based on user input of the line number. echo -n "Delete History Line Number: " read num history -d $num The error is "history ...
3
votes
2answers
592 views

Dowloading all Urls accessible under a given domain with wget without saving the actual pages?

Hi trying to determine all the valid urls under a given domain without having the mirror the site locally. People generally want to download all the pages but I just want to get a list of the direct ...
3
votes
1answer
5k views

Bash: Reverse DNS Lookup of Active IP Addresses

I have a one-line command that lists the top 10 most active IP addresses from a web server access log: cat access.log | awk '{print $1}' | sort | uniq -c | sort -n | tail -n10 A sample result set ...
2
votes
2answers
387 views

Vim is not using Bash's aliases

I am trying to set up Vim so that I can compile C code directly from the editor itself: .vimrc: let $BASH_ENV = "$HOME/.bashrc" autocmd FileType c map <F6> :!gcc -o "%:p:r.out" "%:." ...
1
vote
1answer
178 views

Bash conditional redirection when testing/debugging

What is the best way to conditionally do a redirection in Bash for testing and debugging purposes? In my scripts I add a debug option to show what would have happened effectively doing a test run ...
2
votes
0answers
78 views

SoX fails to concatenate *some* newly generated aiff files

I have a Python script that is using Mac OS X's built in speech synthesis API to create aiff files of some processed text via PyObjC/AppKit. Everything is working fine, but I can't get the aiff files ...
7
votes
1answer
13k views

How can I get the scp command to overwrite the destination folder

I am using the scp command to copy some files to a remote pc, as you do with scp :) I note that the default behaviour of an scp copy for files is to overwrite any existing files. Now I want to copy a ...
3
votes
1answer
221 views

How to clone IO from one terminal to an other

I am connected directly (tty1) and through ssh (pts/0) to my linux box. who pi tty1 2013-09-23 11:33 pi pts/0 2013-09-23 12:17 (192.168.1.26) I'd like to redirect all ...
1
vote
0answers
48 views

Script to port specifc data from doc1 (notepad++) to specific place(s) in doc2

I really appreciate your help with a windows script or regex function that ports specific data from doc1 (xml in notepad++) to specific place(s) in doc2 (notepad++). I'm running win8. Thank you in ...
2
votes
1answer
200 views

How hex command becomes rm -rf ~ / &?

How does the following malicious command become rm -rf ~ / & when compiled? char esp[] __attribute__ ((section(“.text”))) /* e.s.p release */ = “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68″ ...
1
vote
2answers
410 views

Linux/SSH - get EC2 instance to read local .bashrc file

I have a custom .bashrc file with color codes locally on my Linux machine running Ubuntu 12.04 for both my user and root. I connect to Amazon EC2 instances daily running the same distro and would ...
0
votes
1answer
431 views

Logrotate append to existing file and truncate original

Is it possible with logrotate to take the content of a log and add it to an existing file? Like so: 1. Put the content of /var/log/vnc.log after the content of /archive/logs/vnc.log 2. Truncate ...
4
votes
0answers
287 views

bash column command confused by ANSI color escapes

I have a bash script I got from Gary Bernhardt's dotfiles that prints a nice colorized listing of the recent git commits. It uses the column command to line the output up into columns. On my mac, it ...
3
votes
2answers
235 views

How to properly restore settings when running a script using “source”?

I'm writing a script that needs to be executed using source, because its task is to modify the environment. During the script, I want to use set -e so that any error stops the script. The script looks ...
1
vote
1answer
124 views

list screen window number bash

I was wondering if there is a way to get which window number of screen that is active? As in: screen -X get-window-number I have found no way to list screen windows to output, only the actual screens. ...
6
votes
2answers
709 views

How do I make my script ask for a password, like sudo?

I am writing a script which would be potentially dangerous if run in the wrong way. As a safety feature, I want the script to require the user to re-enter their password first, much as sudo does. So ...
2
votes
1answer
229 views

How to get a bash prompt in a ssh tunnel with rsa keys?

After setting client and server with the public keys and allowing PubKeyAuthentication yes, I issue the following command and get a shell that waits indefinitely. mad@amd:~> ssh -T ...
2
votes
1answer
179 views

How can I attach a cygwin script to a keystroke?

I have a script that needs be launch through Cygwin with the following execution /usr/bin/bash -lic "/home/userdude/scripts/scrypty.sh param1 param2" How would I go about setting up a keyboard ...
3
votes
1answer
737 views

Open multiple terminals in a for loop in bash

Recently i changed to lxde on Ubuntu. And after switching it changed my x-terminal-emulator to lxterm. My script was doing the following: Go through a for loop and open a new terminal window and ...
1
vote
1answer
632 views

Split window programmatically with iTerm?

on my development workstation I often have to start the same commands every morning. zeus start, zeus server (booting rails via zeus), redis-server, and like 3 others. I know a lot of people would ...
1
vote
1answer
144 views

SNMPGET/WALK Timeout on Printer

I have an HP LaserJet CP5225n printer that I am using to test SNMP on our network. I'm new to SNMP so I am having trouble figuring out what's going on here. I'm just trying to return the Device name ...
2
votes
1answer
444 views

Delete all file except some in bash, without cd to the directory?

I need to make a daily cleanup in a download directory. I have saw this question and tested the answer rm !("test 1"|"test 4") It work great, but require to have cd to the directory before. Since ...
1
vote
2answers
112 views

Filtering input with sed (regex)

I'm having an issue with sed not returning what I expect when using a regex pattern to clean up some output from a mysql query. mysql -uroot -p -e 'SELECT `path` FROM db.media_gallery' | sed -n -r ...
3
votes
2answers
328 views

restrict rsync (or bash script) to a directory

After a bad accident with rsync deleting wrong files due to wrong destination parameter, I want to restrict rsync (or the bash script running it) to be able to delete/modify files only under a certain ...
1
vote
1answer
130 views

Changing chmod flags back

I'm fairly new to the whole UNIX / command shell sort of stuff, so I apologize for any ignorance for something I am not aware of. And by new, I mean extremely new. I was confused by how to change a ...
0
votes
1answer
219 views

head hangs or doesn't terminate on Linux

I'm using, (uname -a says) Linux ip-x-x-x-x 2.6.21.7-2.fc8xen-ec2-v1.0 #1 SMP Tue Sep 1 10:25:30 EDT 2009 x86_64 GNU/Linux. I've got a script, foo.sh with 100 lines of code and when I run head ...
1
vote
1answer
520 views

FreeBSD csh style history auto completion in bash

I am looking for a way to make it so that my ubuntu bash shell has the same kind of history completion as you get with csh in FreeBSD. The behavior is that on the command line if i start to type ...
1
vote
1answer
1k views

Ubuntu 10.04 using ssh without entering my password

I know questions like this have been asked before, and I have read them all (that I found). The problem I have is that we have an embedded linux device that we can log into for debug purposes by ...
1
vote
1answer
695 views

Bash script fails from Windows 7 task scheduler

In order to use rsync I created a Bash script. It runs fine from the Cygwin 32-bit shell in Win 7 but fails when run from the Win 7 Task Scheduler. My Task Scheduler script is a simple: ...
1
vote
1answer
3k views

Check to see if NGINX is installed on UBUNTU

Is there any or command to check whether NGINX is already installed on UBUNTU Linux using a bash command/script? I was trying something like this echo "BEGINNING INSTALLATION OF NGINX WEB SERVER" ...
0
votes
1answer
421 views

Command-line scp doesn't use case-insensitive autocomplete

Auto-completing filenames (by pressing TAB after first characters of the filenames have been written) is case-sensitive both on my Ubuntu 13.04 box and on my Debian Squeeze box, when I use scp. I ...
0
votes
1answer
278 views

Bash Script can't find command while command can be executed in my bash

I have a Python script that i want to restart if it crashes. So i created a Bash starter script that starts and restarts the Python script in /usr/local/bin/starter Here's the starter script: ...