We've finally moved our websites to a decent host, and for the first time we have Shell Access.
I know very little about using Linux, I can navigate through the file system, read files with Vim and I'm aware of the man command, and I have been able to work out solutions to problems as they show up (eventually), but I know I'm unaware of...
How do I call console/bash commands from inside of a Ruby Program? Also, how do I get output from these commands back into my program?...
Can anyone explain this behavior?
Running:
#!/bin/shecho "hello world" | read var1 var2echo $var1echo $var2
results in nothing being ouput, while:
#!/bin/shecho "hello world" > test.fileread var1 var2 < test.fileecho $var1echo $var2
produces the expected output:
helloworld
Shouldn't the pipe do in one step what the redirection to t...
.bashrc modifications are like nesting for developers. All I have right now is a few aliases and some PATH modifications. What's in yours?...
I have a problem with some zombie-like processes on a certain server that need to be killed every now and then. How can I best identify the ones that have run for longer than an hour or so?...
I'm writing a few little bash scripts under Ubuntu linux. I want to be able to run them from the GUI without needing a terminal window to enter any input or view any output.
So far the only input required is a password for sudo - and gksudo handles that fine.
But I haven't found an easy way to show a message box yet. Is there some kind ...
Given an absolute or relative path (in a Unix-like system), I would like to determine the full path of the target after resolving any intermediate symlinks. Bonus points for also resolving ~username notation at the same time.
If the target is a directory, it might be possible to chdir() into the directory and then call getcwd(), but I r...
If I press ctrl-b that ought to give me ASCII code 2, but ctrl-c is going to be interpreted as a Break.
So I figure I've got to redirect a file in. How do I get these characters into a file?
...
I was looking at http://tldp.org/LDP/abs/html/why-shell.html and was struck by:
When not to use shell scripts
...
Mission-critical applications upon which you are betting the future of the company
Why not?
...
I've created a script that runs every night on my Linux server that uses mysqldump to back up each of my MySQL databases to .sql files and packages them together as a compressed .tar file. The next step I want to accomplish is to send that tar file through email to a remote email server for safekeeping. I've been able to send the raw s...
I have a process in linux that's getting a segmentation fault. How can I tell it to generate a core dump when it fails?
...
I'm writing some documentation in Markdown, and creating a separate file for each section of the doc. I would like to be able to convert all the files to HTML in one go, but I can't find anyone else who has tried the same thing. I'm on a Mac, so I would think a simple bash script should be able to handle it, but I've never done anythin...
I'm looking for shell scripts files installed on my system, but find doesn't work:
$ find /usr -name *.sh
But I know there are a ton of scripts out there. For instance:
$ ls /usr/local/lib/*.sh
/usr/local/lib/tclConfig.sh
/usr/local/lib/tkConfig.sh
Why doesn't find work?
...
Does anyone know how bash handles sending data through pipes?
cat file.txt | tail -20
Does this command print all the contents of file.txt into a buffer, which is then read by tail? Or does this command, say, print the contents of file.txt line by line, and then pause at each line for tail to process, and then ask for more data?
The...
Is there a simple way, in a pretty standard UNIX environment with bash, to run a command to delete all but the most recent X files from a directory?
To give a bit more of a concrete example, imagine some cron job writing out a file (say, a log file or a tar-ed up backup) to a directory every hour. I'd like a way to have another cron job...
Say I have three files (template_*.txt):
template_x.txt
template_y.txt
template_z.txt
I want to copy them to three new files (foo_*.txt).
foo_x.txt
foo_y.txt
foo_z.txt
Is there some simple way to do that with one command, e.g.
cp --enableAwesomeness template_*.txt foo_*.txt
...
I'm accessing an ubuntu machine using PuTTY, and using gcc.
The default LANG environment variable on this machine is set to en_NZ.UTF-8, which causes GCC to think PuTTY is capable of displaying UTF-8 text, which it doesn't seem to be.
Maybe it's my font, I don't know - it does this:
foo.c:1: error: expected â=â, â,â, â;â, âasmâ or â__...
When I do:
$ find /
It searches the entire system. How do I prevent that?
(This question comes from an "answer" to another question.)
...
I want to setup a cron job to rsync a remote system to a backup partition, something like:
bash -c 'rsync -avz --delete --exclude=proc --exclude=sys root@remote1:/ /mnt/remote1/'
I would like to be able to "set it and forget it" but what if /mnt/remote1 becomes unmounted? (After a reboot or something) I'd like to error out if /mnt/rem...
Is there a way to run a regexp-string replace on the current line in the bash?
I find myself rather often in the situation, where I have typed a long commandline and then realize, that I would like to change a word somewhere in the line.
My current approach is to finish the line, press Ctrl-A (to get to the start of the line), insert a...