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

learn more… | top users | synonyms

1
vote
1answer
70 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
127 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
552 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 ...
2
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
105 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
79 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
681 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
314 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
91 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
566 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
210 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 ...
5
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
152 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
141 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 ...
0
votes
2answers
721 views

Run windows bat remotely file from Linux over ssh

It is possible? Cygwin is installed on the windows environment. I connect to windows environment over ssh with follow command: ssh user@ip /cygdriver/c/run.bat. After introducing the password the ...
-1
votes
1answer
216 views

I Can't get the Subl Command to function

I am trying to get the Sublime Text 2 command "subl" to work in Terminal but I am having trouble. I keep getting a "command not found" after it already told me that the file existed. What am I ...
0
votes
3answers
235 views

How to mount a Windows shared drive on OS X given a Windows user like this: myserver@mydomain.com

I have a script in OS X which is something like this: tell application "Finder" try mount volume "SMB://myuser:mypwd@myhost/sharedfolder" end try end tell It works fine, but now ...
4
votes
1answer
941 views

Can I make a custom “directory alias” like '~' in bash?

In bash I can go to my home directory with cd ~ and actually refer to my home directory with any command with ~. Can I make new, custom "directory aliases" (?) to refer to other directories? ...
0
votes
0answers
377 views

Rotate Outgoing Ip in Postfix, script not working

I've found what it seems to be a nice piece of code meant to rotate postfix IP but I really can't get it to work. when I run it I get this error: rotate_postfix_ip.sh: 2: Syntax error: "(" unexpected ...
1
vote
2answers
389 views

comparing two directories and getting the output with absolute path

was trying to compare two directories. one directory is the reference directory(dir1) and the other is the directory where modifications(dir2) are being done I need the list of files which are ...
3
votes
2answers
319 views

Generate distribution of file sizes from the command prompt

I've got a filesystem which has a couple million files and I'd like to see a distribution of file sizes recursively in a particular directory. I feel like this is totally doable with some bash/awk ...
2
votes
2answers
1k views

How to make `script` command loaded automatically on terminal login

script command allows to log gently everything that was put to console during session (like history but also displays results of commands). Everything is logged to file typescript.xxx Now I want to ...
1
vote
2answers
1k views

I want to run an rsync command at midnight but make it stop at 8am. How can i schedule the start AND END of a command?

I want to run an rsync command at midnight but make it stop at 8am. How can i schedule the start AND END of a command? I've looked into cronjobs but that will only start at a certain time. Any ideas ...
2
votes
1answer
711 views

git push to github via cron on mac

I'm trying to use git push in a bash script being run by crontab to push a commit to github. At the end of the script I'm doing this: # script processes some files, then: git add -A git commit -a -m ...
7
votes
2answers
1k views

bash completion for filename patterns or directories

I'm trying to get a bash completion script set up and having some trouble. I would like to set it up so the completions listed are either files matching a particular extension, or directories (which ...
1
vote
4answers
284 views

Emacs tramp mode - filename auto complete doesn't work

I am using tramp mode in Emacs to edit files over ssh. But the problem is that on remote shell I have aliased ls as "ls --color". Tramp uses ls for auto completion and it is unable to parse color ...
1
vote
2answers
121 views

How to set max line in cat command

in grep command I can set max line to output with parameter -m. How I can specify max line in cat command ?
2
votes
3answers
1k views

In bash, how do I pass the while loops input to the cut command?

How do I pass the $line to the cut command properly in this loop? while read line do login= $(cut -d : -f 1) done < /etc/passwd I can't do $(cut -d : -f 1 $line) so what is the correct way? ...
2
votes
1answer
968 views

Why would setting the prompt in .bashrc not actually affect the prompt?

I am trying to set my shell prompt by inserting the following line into .bashrc in my home directory: export PS1="\[\e[01;36m\][\u]\[\e[0m\] \[\e[01;37m\]\W\[\e[0m\] $ " I save this file and ...
0
votes
3answers
184 views

output the items that showed up 2 times and more

How can I select the ips that showed up 4 times or more , for example here? the input file is 192.168.1.28 192.168.1.100 192.168.1.31 192.168.101.2 192.168.1.31 192.168.11.02 192.168.1.31 ...
1
vote
6answers
445 views

match string in awk

How can I search the file to find the lines that have SRC= , for example here? i mean how can i find source IP address in this file using awk for example Mar 10 03:17:12 ubuntu kernel: ...
3
votes
1answer
95 views

bash - i'm doing for i in *.mp4, then in the loop i want to use ${i} but without the .mp4. how can i do this?

Basically i am doing this: for i in *.mp4; do ffmpeg -i "${i}" -vf "movie=logo.png [watermark]; [in][watermark] overlay=10:10 [out]" -strict -2 -qscale 0 "${i}-watermarked.mp4"; done; but this ...
0
votes
2answers
54 views

working directory deleted

There are some 4 people who know my root password.And someone deleted my code directory. We have a single system where everyone has his own code base directory and everyone ssh to this system and ...
4
votes
1answer
979 views

Homebrew: Terminal Emoticons How?

I use homebrew for package management on my mac. Today after updating homebrew I saw something I've never seen before; There was a tiny beer emoticon in the terminal. How is this being done!? What ...
4
votes
5answers
346 views

Save command to history without executing in bash

Is there a way to save a command in bash history without executing it? e.g. $ cmd [a long list of arguments] and now during typing i remember I'd like to do something else first. Can I have ...
0
votes
1answer
109 views

bash call command on $var value

I am new to shell scripting and stepped through this quick guide: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html which was helpful but left a lot of questions about working with variables ...
1
vote
1answer
299 views

Auto-mount usb flash drivers for remote servers using bash file for scheduled backup operation

I have to do scheduled backup of servers' databases using a cronjob for the backup task and a bash script for the backup operation. It's a PHP web application. You can choose to store your backup file ...
1
vote
1answer
416 views

Messed up /etc permissions

I was going to modify my.conf file so I wanted to change its permissions, but I ran the code in the current dir instead of only the file Now all files in the /etc (and the folders) have 777 ...
0
votes
3answers
109 views

Bash PS1 string that evaluates certain code every time it is looked up

This question is very similar to this one: Colored PS1 string But I still don't understand completely. So say I have this function function getjobs { echo $(jobs | wc -l) } And my PS1 is ...
0
votes
2answers
2k views

Why does my Bash script display the “too many arguments” error at the cp command?

Here is my script, I get the error "line 33: [: too many arguments", I'm confused why, surely only 2 arguments are being provided to cp here? I am providing two directories to the script with no ...
1
vote
3answers
62 views

How do I get multiple scripts prompted with an alias in Cygwin?

I want to run one command, then bring up a second, but modify it first before pressing enter on it. (Cygwin) I usually just type it all out like this: svn up 8.0; ./merge.py 8.0 12345 I also have ...
4
votes
4answers
4k views

To know which IP executed a certain command in linux using ssh

There is a server which is accessed by many users using ssh. I am trying to figure out which user executed a certain command. I can know the list of users currently accessing server using who Also I ...
4
votes
1answer
656 views

Whats the meaning of “set -o emacs” command?

Whats the meaning, or what it does: set -o emacs ? I saw it somewhere, and I a emacs user, so It make me curious.
0
votes
1answer
729 views

How to escape the arguments correctly when calling cygwin bash -c?

I am trying to call the scanimage command (from the SANE tool) from inside cygwin though I think that my problem is one of general escaping so maybe what I am calling doesn't matter. Anyway... The ...
3
votes
2answers
2k views

SED: How can I print every line after first instance of string using Sed?

I have a file with a similar format... 16:28 asdfasdf 16:29 4398upte 16:30 34liuthr 16:31 34tertio How can I use SED to print out every line including and after the line with "16:30"? The result ...
0
votes
3answers
342 views

Break out of nested functions in a shell

If I have a series of nested functions, how can I break out of all of them from the innermost function? EDIT: Busy looking into the builtin 'trap'...
2
votes
1answer
381 views

How to restrict cygwin's permissions in Windows 7

After an... ahem... incident involving an ill-judged rm -rf, it occurred to me that if you have administrator permissions on your Windows machine, working within a Cygwin terminal is the equivalent of ...
7
votes
3answers
967 views

Is there a shell which supports fuzzy completion as in Sublime Text?

I'm using bash and I was wondering if there is any plugin in bash or other shell which allows me to do this cat tfnislong.txt + [tab] completes to cat ThisFileNameIsSoLong.txt just like tab completion ...
5
votes
3answers
261 views

Can bash consume the same fifo from two separate commands?

I have a huge data source that I'm filtering using some greps. Here's basically what I'm doing right now: #!/bin/bash param1='something' param2='another' param3='yep' echo $(avro-read /log/huge_data ...
4
votes
1answer
262 views

Diff between two directories and keep only the unchanged ones

I need to diff two directories: A: /path1/ B: /path2/ The directory A contains all files and subdirectories that are also contained in B. The files in A (and in its subdirectories) can have ...