Bash is a free shell for Unix-like operating systems, from the GNU Project
2
votes
1answer
25 views
Running `cp -r ~/.ipython ~/some/path/.ipython` a second time creates `~/some/path/.ipython/.ipython`. How to prevent that?
I am using a script to copy directories to a specified location. When I run cp -r ~/.ipython ~/some/path/.ipython the .ipython dir is copied as expected to the specified location. But when I run this ...
0
votes
1answer
21 views
sed command working in command line but not in script
I have a script with the follow code:
find . -name "*.html" -print0 | while IFS= read -r -d '' n; do
sed -i -r 's/<font ...
0
votes
1answer
14 views
Why the command substitution in the crontab job doesn't work?
crontab -l:
* * * * * /Users/michel/Desktop/myScript.sh
myScript.sh:
#!/bin/bash
/usr/local/bin/growlnotify -t 'Fact' -m "$(/Users/michel/Desktop/anotherScript.sh data.txt)" -n 'myApp'
it ...
1
vote
2answers
12 views
How do I show the real current directory in my bash prompt, not the symlink
I use the default value of PS1 shipped with Ubuntu:
\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$
which is ok 90% of the time. However, when I cd to a symlink "directory" the ...
3
votes
1answer
11 views
Linux History Display Dates
I added date and time to my linux history with this command:
export HISTTIMEFORMAT='%F %T '
When I actually go to view my history anything that I didn't actually do today seems to pick a time that ...
1
vote
2answers
46 views
How to save echo result into a variable?
I have this output from a s3cmd ls --list-md5 command.
2013-05-22 12:20 1965154 41eae9b40d23de2f02bf07635870f6d0 ...
3
votes
2answers
70 views
Found a script on my cron.monthly, i am wondering what's it doing?
I am new to bash-programming, sorry if this might be a kind of stupid question. I found a script on my server and i am trying to understand every line:
#!/bin/sh
#
# man-db cron weekly
set -e
if ! ...
1
vote
1answer
8 views
rsync: Can it transfer files ignoring size (comparing only timestamp and name)?
Can rsync compare/copy based on mod date and filename alone, ignoring file size?
Context:
I'm trying to implement a two-stage backup using rsync. The first stage is onsite, and I have a bash rsync ...
2
votes
1answer
16 views
What is the difference between bash and -bash?
What is the difference between bash and -bash. When I execute echo $0, it returns bash on one machine and -bash on the other machine. What is the difference between them?
3
votes
1answer
84 views
How to `rm *`, an actual file named “*”? [duplicate]
I don't know how this happened, but I have a broken symlink in my home directory named *. I was just about to rm *, and then I had a facepalm moment. Should I rm \*? rm '*'? Something else? Backing up ...
0
votes
1answer
11 views
What is the proper way to shell script a start / stop process that is triggered by another process?
Program 1 runs irregularly, and crashes program 2, which then crashes program 1.
I'm not able to find the proper way to make program 2 stop when program 1 is initiated, and then restart program 2 ...
2
votes
1answer
27 views
How to change the resolution of the Bash for a Debian VM?
I'm trying to learn how to use Linux with a Debian 7 VM that has no GUI.
The 640x400 window I'm working in feels a little constricting and would like to make it bigger, say 1024x768.
How can I do ...
0
votes
1answer
31 views
Locking a GNU-screen session after x minutes of non-use on Linux
I have a couple of services running in a GNU-screen session on top of Bash. Because one of the services contain sensitive data I have to constantly either close the terminal completely or lock the ...
2
votes
2answers
17 views
How to recover bash output of an already closed window?
I have run a specific program in a bash terminal and I closed it by mistake before reading its output. Is it possible to recover the information that was sent to the stdout by taking a look at some ...
3
votes
4answers
20 views
How to send an `xmessage` as root remotely to regular user logged in with 'x' session?
I'm using BASH on the command line, logged into another user's PC as root, via SSH.
I wish to send the user currently logged in running an X-session, a popup message, but this is the result:
...
1
vote
0answers
13 views
gnome-terminal - color palette
I'm trying to assign color palette on my gnome-terminal but it doesn't change at all... any clue?
Screenshot > http://i.imgur.com/MXXhoOo.jpg
Aditional info:
Fedora 18 64bits (shiny new)
GNOME ...
0
votes
1answer
18 views
Why echo $(crontab -l) outputs current working directory listing and only then the content of crontab file itself?
So if cwd is the /tmp now:
crontab -l
> #min hour day mon dow command
> * * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw
but:
echo $(crontab -l)
> ...
0
votes
1answer
16 views
Remove file extension in OS X using Terminal
Problem:
I have some 200+ files named something in line with "DSC01852.JPG.jpg". I would like to remove the file extension so the result becomes "DSC01852.JPG".
Any suggestions? I looked at the mv ...
0
votes
1answer
32 views
Merge three files into one in a bash script
I have a series of folders containing three files that I want to concatenate as part of a script.
The three files are named file.html1 file.html2 file.html3. I want to concatenate them into file.html
...
0
votes
0answers
31 views
what does “cd //” do in linux? [duplicate]
I'm running Ubuntu 12.04 and in bash, when I type cd // I get to what looks like root. However, the pwd command yields //. I can create files, and everything seems to behave like normal bash, just ...
1
vote
1answer
26 views
How to convert ASCII character to integer in bash?
I'm parsing an ntpq output to pass its contents to our database via console utility. The first element is a one character substring containing status of the remote. It can be "*", "+", "o", "#" etc. ...
1
vote
2answers
44 views
Difference between almost the same directory commands
Is there any difference between these (almost the same) directory commands?
1. cd
2. cd ~
3. cd ~/
I tried it in my shell, and they all lead to the home directory. Is there any possible scenario ...
1
vote
0answers
41 views
File shows different size after copying to another directory
I used cp -rP <dir name> <new dir name> to copy the contents of a directory, including permissions etc from one dir to another. The odd thing is, either du is giving me some strange ...
0
votes
1answer
30 views
How do you remove nested empty directories using a Bash script on Linux?
I want to be able to run a script that will remove all my empty directories. The problem is some of them are nested, i.e. directories that only have empty directories in them, so the script needs to ...
11
votes
2answers
240 views
Why does redirecting the output of a file to itself produce a blank file?
Why does redirecting the output of a file to itself produce a blank file?
Stated in Bash, why do
less foo.txt > foo.txt
and
fold foo.txt > foo.txt
produce an empty foo.txt? Since an ...
0
votes
2answers
45 views
Replacing a dot with an underscore in a file using sed
I was trying to edit the output of a file using sed. The contents of file are
cat /tmp/Group_RM
t.p@k.p
t.m@k.k
I was trying to get the output as:
cat /tmp/Group_RM
t_p@k_p
t_m@k_k
I tried the ...
4
votes
1answer
78 views
How to execute bash script without password?
I need to execute the script after system boot. For example:
(sleep 5 && (sudo dhcpcd wlp4s0))
What I need: Executing the script. What I have: [sudo] password for eugene: I has been edited ...
1
vote
1answer
35 views
Pass result of the command to exec
I have a kind of "bash newbie" question: how do I pass the result output of one command to exec. The result of the first command is the name of other command, so exec should be able to execute it.
59
votes
6answers
2k views
How do perform commands in another folder, without repeating the folder path?
I was wondering if there's any clever way to do copy and move operations, or if there's a command to duplicate a file, without having to do a cd, then mv after, at the same folder.
For example, I ...
2
votes
2answers
40 views
SSH remote command no reading all environment variables
I have declared some "PATH" variables in the ".bashrc" file of a remote machine. When I login to the remote machine, all these "PATH" variables work fine. But when I do a "ssh user@remote env", the ...
0
votes
0answers
14 views
How do I change my bash prompt to say the user I'm logged in as + my current directory? [duplicate]
What I mean is, right now my bash prompt looks like this:
http://puu.sh/2UH1K.png
I want it instead to say:
{username} @ {current directory}
(EG: root@/home/public_html/ ~)
1
vote
1answer
35 views
How do I install 'z' file directory jumper on linux?
I'm attempting to install this and running into issues. I am supposed to add a line to the ".bashrc" file? Where in the file? the bottom? the top? somewhere in the if statement? do I make it an alias?
...
0
votes
0answers
14 views
paravirtualization using xen in debian wheezy
i have been trying to run av virtual machine using xen but in the end i always get the error
chroot: failed to run command `/sbin/shadowconfig': Exec format error
hook 05-shadowconfig-on: done.
...
0
votes
0answers
8 views
Going back to a stopped job [duplicate]
wim@wim-zenbook:~$ ipython
Python 2.7.4 (default, Apr 19 2013, 18:28:01)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- An enhanced Interactive Python.
? ...
0
votes
0answers
25 views
udev rule not working on Debian [closed]
I have created a udev rule which is supposed to mount a USB device, backup some data and clean up everything. I am actually working on a Debian server.
Here is the information about my USB device ...
1
vote
2answers
32 views
Is it possible to run software as a different user under OS X Mountain Lion?
I've been trying to run apps as a different user.
Attempt 1
sudo -u otheruser open /Applications/TextEdit.app launches the app but it uses the current user, not otheruser.
Attempt 2
login username ...
1
vote
1answer
43 views
Where to store bash scripts that all users may execute on Debian?
I have many bash scripts on my server, that all users may use.
but it seems the location
/usr/local/sbin
is not the best place.
I don't want to use the home directory of the users, cause ...
0
votes
2answers
27 views
how do I add /usr/local/sbin to the PATH of a user? [duplicate]
if I type
echo $PATH
I only get
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
how can I add /usr/local/sbin to the path, so it is already there the next time?
(I use debian ...
2
votes
3answers
77 views
Is it possible to put foreground process into background without suspending (control +z)?
I am running an application which receives TCP and UDP packets and therefore cannot be suspended. I intially ran 3 processes of the same application, with different arguments, in background mode using ...
0
votes
1answer
35 views
Prevent users from being able to pipe output to another users terminal?
So currently on this server if two people are logged into the same server, you can do something like:
-bash-4.1$ cat /dev/urandom | write username
It will print a bunch of junk to their terminal. I ...
0
votes
1answer
51 views
rm the current directory you are in and issues surrounding it
If I cd to a directory, is there a quick way to delete the directory I am in and move to the top directory? Usually I cd to a directory, ls it and then cd .. then delete the folder. I want to be able ...
0
votes
0answers
41 views
Why does my mv command require an absolute pathname? [closed]
Moving a file from my current directory with
mv bar.txt ../../foo/current
mv: cannot move `bar.txt' to `../../foo/current': No such file or directory
fails, but using the full path as in
mv ...
0
votes
1answer
29 views
Use a modern locale, but retain asciibetical sorting?
I bought a new laptop (an Ideapad Yoga), and put Linux Mint on it. Everything seems to be working well, but Mint's default LOCALE settings for my language choice (en-CA... not sure why CA when I'm in ...
0
votes
2answers
28 views
Prepend prefix in tar
I currently do in a shellscript very inefficiently:
cp -a $MYPATH /tmp/$VERSION
cd /tmp
tar cjf archive.tar.bz2 $VERSION
I want everything to be contained in the directory called $VERSION - is ...
0
votes
2answers
57 views
Throttle CPU based on Temperature? - Ubuntu
I was running some programs on my Ubuntu machine that use max CPU power for extended periods of time. This causes the computer to overheat.
Could someone suggest a good program that will throttle ...
0
votes
1answer
14 views
Modify Several Plist Using a Script
defaults read /New.plist itemName
the Output Will Be Some Thing Like "Software"
but i want the new Data to be updated for the key as "Software Old Version"
the problem is i have to modify several ...
3
votes
2answers
36 views
Append line break to command output
I have a single-line command that does a curl request to check server status and then output the result to a log file. But the problem is the returned result has no line break and so the log file ...
1
vote
3answers
95 views
How to paste multiple Bash commands into a shell without losing some?
It's nice to copy-paste a series of Bash commands that you find on a website. But depending on the commands, sometimes you lose a few. Maybe they get swallowed up by programs that read from standard ...
1
vote
3answers
82 views
Rename recursively files, while keeping the extension
I have a bunch of directories that each hold one *.txt file in it (and other non *.txt files).
I'd like to rename those files recursively from the command line, basically *.txt to info.txt.
So all ...
0
votes
4answers
14 views
short alias for file in bash command
I want short way to access files, which i usually use in bash.
For example, see logs. Now i use:
less /var/log/user/server.log
less /var/log/user/server2.log
I want shortcut, to do
less server.log
...



