G'day,
I need to see if a specific file is more than 58 minutes old from a sh shell script. I'm talking straight vanilla Solaris shell with some POSIX extensions it seems.
I've thought of doing a
touch -t YYYYMMDDHHmm.SS /var/tmp/toto
where the timestamp is 58 minutes ago and then doing a
find ./logs_dir \! -newer /var/tmp/toto -pr...
Is there anyway to pipe the output of a command which lists a bunch of numbers (each number in a separate line) and initialize a bash array with those numbers ?
Details:
This lists 3 changelist numbers which have been submitted in the following date range. The output is then piped to "cut" to filter it further to get just the changeli...
Pretty much every product I've worked on over the years has involved some level of shell scripts (or batch files, PowerShell etc. on Windows). Even though we wrote the bulk of the code in Java or C++, there always seemed to be some integration or install tasks that were better done with a shell script.
The shell scripts thus become par...
I have been in love with zsh for a long time, and more recently I have been discovering the advantages of the ipython interactive interpreter over python itself. Being able to cd, to ls, to run or to ! is indeed very handy. But now it feels weird to have such a clumsy shell when in ipython, and I wonder how I could integrate my zsh and m...
In my web application I render pages using PHP script, and then generate static HTML files from them. The static HTML are served to the users to speed up performance. The HTML files become stale eventually, and need to be deleted.
I am debating between two ways to write the eviction script.
The first is using a single find command, lik...
I find grep's --color=always flag to be tremendously useful. However, grep only prints lines with matches (unless you ask for context lines). Given that each line it prints has a match, the highlighting doesn't add as much capability as it could.
I'd really like to cat a file and see the entire file with the pattern matches highlighted....
I am maintaining a Grails application that I did not write(I have no experience with Groovy/Grails, actually :)) and it currently has a bug on one of the environments it's deployed on, but not others.
In order to debug this, I want to jump into the grails shell on the affected server, run the command that I suspect is error-prone, and s...
Is there a simple shell command/script that supports excluding certain files/folders from being archived?
I have a directory that need to be archived with a sub directory that has a number of very large files I do not need to backup.
Not quite solutions:
The tar --exclude=PATTERN command matches the given pattern and excludes those fi...
Guys, is there an alternative to "tee" which captures STDOUT/STDERR of the command being executed and exits with the same exit status as the processed command. Something as following:
eet -a some.log -- mycommand --foo --bar
Where "eet" is an imaginary alternative to "tee" :) (-a means append, -- separates the captured command) It shou...
When you right-click an .exe file, you can see various details, such as file description.
I'm looking for way to retrieve that data programmatically (preferably, from C#).
(Program's name, program's description, Vendor's name, Vendor's site etc)
...
In bash, is there a way to chain multiple commands, all taking the same input from stdin? That is, one command reads stdin, does some processing, writes the output to a file. The next command in the chain gets the same input as what the first command got. And so on.
For example, consider a large text file to be split into multiple files...
I want an "eternal" process that goes through a MySQL table and spawns child processes. Pseudo code:
while(true)
$rows = SELECT * FROM workers
foreach($rows as $row){
DELETE $row->id
spawn_child($row->id)
}
sleep(5)
}
function spawn_child($id){
$pid = pcntl_fork()
if($pid <0){
//err
...
Most scripts that parse /proc/cmdline break it up into words and then filter out arguments with a case statement, example:
CMDLINE="quiet union=aufs wlan=FOO"
for x in $CMDLINE
do
»···case $x in
»···»···wlan=*)
»···»···echo "${x//wlan=}"
»···»···;;
»···esac
done
The problem is when the WLAN ESSID has spaces. Users expect to set wlan='...
In my .zshrc, I use the following snippet to integrate the shell's clipboard and my primary X11 clipboard. Thanks to this integration, I can cut-and-paste text to and from emacs, firefox, and the terminal without having to use the mouse.
kill-line() { zle .kill-line ; echo -n $CUTBUFFER | xclip -i }
zle -N kill-line # bound on C-k
yank...
I created a new FIFO using the 'mkfifo' command. I have a text file f.txt.
I want to write the text file into my FIFO. How? Is there a unix command for that?
...
I'm trying to change the directory of the shell I start the ruby script form via the ruby script itself...
My point is to build a little program to manage favorites directories and easily change among them.
Here's what I did
#!/usr/bin/ruby
Dir.chdir("/Users/luca/mydir")
and than tried executing it in many ways...
my_script (this do...
I'm trying to use python to sftp a file, and the code works great in the interactive shell -- even pasting it in all at once.
When I try to import the file (just to compile it), the code hangs with no exceptions or obvious errors.
How do I get the code to compile, or does someone have working code that accomplishes sftp by some othe...
I'm trying to port a script from BASH to ASH (Almquist SHell) and am running into a problem with indirect references. The following function
cmd() {
# first argument is the index to print (ie label)
arg=$1
# ditch the first argument
shift
# print the label (via indirect reference)
echo "${!arg}"
}
should produc...
When using svn, and I want to check in the entire local repository, I cd into its directory and type:
svn commit -m "blah blah"
I quickly realized (the painful way) that this doesn't add new files automatically.
In order to do that, I'm performing this two step hackasstic monster:
find . | grep -v ".svn" | grep -v "ignorepattern" | ...
When we enter:
ps -f
... the CMD column text doesn't show the full command. Any way to prevent this truncating?
Seems like it's showing the first 80 characters. We are running a fairly log command that has lots of command line switches.
Thanks for the responses.. doesn't seem like any of these do the trick though..
...