1
vote
3answers
55 views

How to stop bare bash cd (change directory command) from changing the working directory to $HOME?

I do this too often: $ pwd /a/long/long/way/from/anywhere $ cd # oops - meant to tab-complete something /home/$USER Can cd defaulting to $HOME be disabled?
10
votes
2answers
213 views

backslash at the beginning of a command

In Installing RVM manual I see a lot of lines starting with '\': Install RVM with ruby: $ \curl -L https://get.rvm.io | bash -s stable --ruby I'd think it is just mistype but they repeat ...
0
votes
2answers
83 views

special characters in http_proxy environment variable

What is the correct format using special characters in http_proxy environment variable? Or to be mor specific, what to do with special characters in username or password when authenticate to http ...
-3
votes
2answers
199 views

How to find files of certain extension and tar each of them in to another location

I have script for finding files of certain type and compress them to a single tar archive and put in to other place. But now, there is a change in requirement, that I need to find files of certain ...
0
votes
1answer
89 views

How to combine outputs of ps and lsof

Usually output of ps has a pid somewhere. Is there a way to combine this, preferably with a one-liner, with an output of lsof ? e.g. 27915 ? Ss 0:03 gpg-agent --daemon gpg-agent 27915 ...
3
votes
2answers
87 views

Rename a directory containing many files

I made a mistake in a rsync and all the files are copied long with its full path. All the files that I copied are at /var/www/photos/2012/1007/1007 Attempt 1 Now I would like to fix the paths, by ...
0
votes
3answers
192 views

Files copying between servers by creation time

My bash scripting knowledge is very weak that's why I'm asking help here. What is the most effective bash script according to performance to find and copy files from one LINUX server to another using ...
0
votes
2answers
175 views

how to check how many minutes have passed since the user is idle? [closed]

I want to write a script that will show how many minutes the user is idle. Since the last touch of the keyboard and mouse. Example: #!/bin/bash while true do command_lines... ... sleep 60 echo ...
2
votes
1answer
78 views

Unix Command to timestamp the output of a file, but with the relative-to-when-it-started time?

There are numerous programmes (e.g. ts in moreutils), and various bash one-liners to prepend the output of a command/pipe with the timestamp of when that line was 'printed'. However is there a ...
10
votes
4answers
489 views

How would you simplify this command?

I'm quite new to strace / netstat / etc. I'm using this command to get a trace of the apache process handling my request (telnet), is there a way to simplify it a bit? sudo strace -o /tmp/strace -f ...
1
vote
1answer
575 views

pgrep/pidof usage for complex process names?

I am trying to use pidof or pgrep to be able to send a HUP to a process in my system. The problem is that I only want to kill the process with a precise parameter. This is the output of 'ps awx' ...
1
vote
4answers
263 views

Concatenate variable in string bash

I want to kill a process in specified port (variable) export PORT=3030 netstat -ntlp | awk '$4~/:*${PORT}$/{gsub(/\/.*/,"",$NF);cmd="kill -9 "$NF;system(cmd)}' but variable PORT doesn't get in the ...
3
votes
2answers
266 views

sudo -i but keep current working directory

When use sudo -i I will simulate login as root, and current working directory will be jumped to /root. Is it possible not to jump and keep the working directory unchanged? Thanks
0
votes
1answer
94 views

mysqldump asking for password even after telling it the password in the command line option

I am using the following command: mysqldump -alv -h 123.123.123.123 --password=P@ssw0rd --user=UsernameHere --add-drop-table -p DatabaseSchemaName > dump.sql Then it asks me to Enter Password. ...
1
vote
2answers
117 views

Bash Command Line In-Line Array

Any bash gurus know how to turn the commands below into a one liner? trutch:$ touch app/views/pages/_sponsors.html.erb trutch:$ touch app/views/pages/_donations.html.erb trutch:$ touch ...
12
votes
2answers
529 views

What is the difference between sudo -i and sudo su -

What is the difference between commands sudo -i and sudo su -? Are they the same?
1
vote
2answers
1k views

Sending mail from command line if body not empty

I'd like to write a simple script that alerts me if a log changes. For this I'm using grep to find the lines I'm interested in. Right now it works like this: grep line /var/log/file | mail -s Log ...
0
votes
4answers
267 views

“Command not found”-unable to run the bash script [duplicate]

Possible Duplicate: My cron tasks report command not found I am trying to run a bash script #!/bin/bash export AWS_CLOUDWATCH_URL=https://monitoring.amazonaws.com # get ec2 instance id ...
2
votes
2answers
325 views

BASH: Newline or HR after long command output

Is there any way to configure Bash to print a newline or horizontal line after commands that provided more than N lines of output? For instance, after a simple cd I don't need a newline or horizontal ...
2
votes
1answer
153 views

What does the leading dash in process cmdline mean?

I noticed a process taking full CPU on my linux server, of which the COMMAND column from top -c is -bash. cat /proc/<pid>/cmdline shows -bash too. What does the leading dash mean? More info: ...
13
votes
3answers
608 views

Strange bash history behaviour when running multiple sessions

How is command line history stored when I use multiple terminal windows? I know it is stored in .bash_history but I can't see the logic on what history is used if I open new window. It almost feels ...
75
votes
25answers
18k views

How do I prevent accidental rm -rf /*?

I just ran rm -rf /* accidentally, but I meant rm -rf ./* (notice the star after the slash). alias rm='rm -i' and --preserve-root by default didn't save me, so are there any automatic safeguards for ...
1
vote
1answer
290 views

Can't change path location of PHP on mac os x snow leopard

I have XAMPP installed on my mac, and I want to make command line PHP use the same executable as XAMPP since I've customized that php's php.ini file. The php binary I want is located at: ...
0
votes
3answers
502 views

Cannot remove or list directory (ls or rm) Linux - Debian

I have a log file directory at /var/log/apache2/vhosts on a Debian dedicated server. Every day I split the main access_log into respective vhostname.com_access_log files in /var/log/apache2/vhosts In ...
0
votes
1answer
86 views

bash script parameters & error trapping

I've created a bash script for a cron job that I'm using to convert an uploaded file to a couple of formats and then moving it to another folder where another cron job will store it away, etc. The ...
1
vote
2answers
127 views

How do I execute a sequence of commands by writing one line in bash? [closed]

With cmd.exe's interpreter this is easy: echo testline > .\test.txt && c:\windows\system32\notepad.exe .\test.txt What is the equivelent to this with bash? For instance, vim doesn't ...
1
vote
3answers
125 views

Run another command if there is any input on the standard input

How can I run another command if there is any input on the standard input commonly used in situations like this: some command with no normal output | ifinput mail -s 'some output' me
2
votes
2answers
481 views

prevent xargs from quitting on error

According to the man page, xargs will quit if one of the execution lines exits with an error of 255: If any invocation of the command exits with a status of 255, xargs will stop immediately ...
1
vote
1answer
1k views

Pass password to adduser command

Just wondering if it's possible to pass the password I want to use to the adduser command in ubuntu, so that it can be automated. I want to do something like this echo "password" | adduser test ...
-1
votes
2answers
1k views

Bash ping successful program

I'm thinking that this needs to be changed to a while loop because, at the moment, it'll wait untill all 10000 pings are done. I need this to return when the ping is successful. What are your ...
1
vote
3answers
280 views

how i can get the date in UNIX-aix and store ecah part in variable

I write batch file and i want to compare the modification time (timstap) to two folder and copy the latest one . i don't know if this option available directory be cause i don't know .so i want to get ...
3
votes
2answers
218 views

Command Line One-Liners: Quick & Dirty “Bytes Transferred” report

Alright. So we have a lighttpd server pumping out the loading of our images. It logs on a daily basis, and we're considering moving all those images to our S3 account for better load times, but ...
6
votes
3answers
224 views

Keyboard shortcut to store typed command and clean the line

You know the situation: You are halfway through typing a long command (for example a commit message) and realize that you have forgotten to execute some prerequisite command that can not be added with ...
2
votes
3answers
662 views

Use SSH to execute remote export command and stay logged in

I have a simple problem of needing to execute an export command over ssh, and then stay logged in, but I'm having some trouble. Though I am interested in a solution to this problem for many reasons, ...
0
votes
2answers
139 views

what does the command bash do when typed in a linux terminal? [closed]

When I type bash in to linux cli, it gives me bash-3.2$ so what does it do?
1
vote
2answers
767 views

modification time rsync option?

i use rsync tools between two server but it seem rsync make synchronous between servers according to file size and i need to make synchronous according modification time please how i can do it for ...
0
votes
1answer
210 views

calling a different python interpreter from bash command line

I have python 2.7 installed [user@localhost google_appengine]$ python Python 2.7 (r27:82500, Sep 16 2010, 18:03:06) [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2 Type "help", "copyright", ...
8
votes
2answers
5k views

Using bash, how can i find out the average, max and min from a list of numbers?

I have a series piped greps, awks and seds which produce a list of numbers, one on each line. Something like this: 1.13 3.59 1.23 How can i pipe this to something which will output the average, ...
2
votes
3answers
514 views

Handy parsing for numbers with unit suffixes?

Let's say you have data with quantities in human-readable format, such as the output of du -h, and want to further operate on those numbers. Let's say you want to pipe your data through grep to do a ...
3
votes
1answer
1k views

Screen -X exec commands not working until manually attached

I have a batch script that starts a java server application inside of a screen. The command looks like this: cd /dir/ && screen -A -m -d -S javascreen java -Xms640M -Xmx1024M -jar ...
0
votes
1answer
89 views

Toggle Foreground Process

Ctrl-z suspends the foreground process, but when there is nothing in the foreground it has no effect. I want to overload ctrl-z so when there is nothing in the foreground it brings the most recently ...
0
votes
4answers
203 views

Removing old cache files - command help

I'm trying to write a command to help clear up old cache asset files. The files are always either .css,.javascript,.css.gzip or .javascript.gzip and i want to delete all files older than 2 days old. ...
1
vote
1answer
144 views

how i can write if statment in unix AIX

i want to write if statment as following :- if [$x == "string"] then echo "ok" fi but the following error appear ./bash_if.sh[6]: [0: not found.
2
votes
2answers
232 views

Please explain this BASH code (one line)

Never seen this used before in BASH: pidfile=${PIDFILE-/var/run/service.pid} The part I've never seen/used before is the ${PIDFILE- part.
0
votes
2answers
143 views

syntax of switch statment in Unix SunOS 5.9?

I have been searching for the proper Syntax to a switch statement for Unix SunOS. It seems I'm out of luck, perchance anyone can post an example?
0
votes
1answer
105 views

how i can send and get file by using sftp?

how i can send and get file by using sftp ????
0
votes
3answers
248 views

canceled sftp password Requests?

i write bash file contain sftp command ... but i have problem every time i execute bash sftp requests password of the remote server .. how i can give sftp password as default parameter ???
0
votes
2answers
755 views

sftp remotly copy in bash file “unix”?

how i can write bash file to copy files from unix box to windows "remotly" box by sftp command ???
0
votes
1answer
301 views

bash file to send an e-mail in unix?

i want to write bash file perform the following steps :- copy file from server1 to server2 if (copy success ) do nothing if (copy failed ) send e-mail to admin@company.com contain the following ...
-1
votes
1answer
203 views

how i can Find the files inside the folder and save the file names in variables?

how i can write bash file to Find files (number and name of files are variable) inside the folder and save the file names in variables ?

1 2