Just out of curiosity, is there any method in Linux to know the number of files in a directory in O(1) (independently of the number of files) without having to list the directory first?
I'm searching for an alternative to ls | wc -l.
Thanks!
...
Hi,
I want to replace Windows 7 Shell (32 and 64 bit) with my WPF application which should work as a Shell. The goal is WPF application will launch my Kiosk application and provide few services.
My questions are
How do I replace the Windows 7 Shell by my
WPF application ?
Do I have to do
something special in my WPF
application code ...
I have 2 two files
$cat file1.txt
field1=value1
field2=value2
field3=value3
::
::
$cat file2.txt
something.field1.some
otherthing.field2.anything
anything.field3.something
I need to read file1.txt and check whether file2.txt for fieldN and replace with valueN
so that the result will be
something.value1.some
otherthing...
I would like a command line function that I can run on any file to change the include("myinc.inc"); PHP statement to include 'myfile.inc'; I have made a start by adding the following to my ~/.bashrc file:
function makestandard() {
perl -p -i -e 's/include\("([\w\.]+)"\)/include '$1'/g' $*
}
I source ~/.bashrc; and run the command ...
I have a Cshell script that I am modifying to have related input and output locations.
the functionality all happens in a foreach loop like so:
set INPUT_LOCATION_LIST = "loc1 loc2 loc3 loc4"
foreach location ($INPUT_LOCATION_LIST)
#***Do some stuff ***
end
I would like to have an output list with different values than the input list...
Is there a way to put the terminal on the web browser instead, so I just fire up localhost:80 and then I'll have a terminal on it that I can use and whatever I execute it will execute on my local web server?
And the outputs I want to be displayed on the web browser too, just like a normal Terminal.
I'm using Ruby on Mac OS X/Ubuntu.
...
Hi!
I am trying to use the simple fuinction below. But i get error sayin unary oprator expected and the output is always one. Can any1 help me correct it.
#!/bin/bash
checkit ()
{
if [ $1 = "none" ]
then
echo "none"
else
echo "one"
fi
}
checkit
...
I try to execute shell commands, this does work as it should. Even the result comes back (as is see on LogCat). The problem ist the last line of the result. Every time a readLine() on the last line occurs (which shouldn't occur, temp should be null), the app hangs forever and doesn't come back from the readLine call. Maybe you find the ...
Here's what I'm trying to achieve.
I have a directory with over 4200 sub-files/sub-directories, all of which need to be set to a certain timestamp.
This is a problem because many of them have whitespaces and other weird characters.
First thing I tried:
touch $(find .)
Won't work because of the spaces. It will update the timestamps o...
Using the following code I can run Excel from within C#:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.Start();
Can I make Excel start hidden or minimized using any command line parameters?
(Edit: Tried p.StartInfo.WindowStyle and it had no effect.)
I need to start Excel without...
I have a script I want to execute with open4.
Here is the file:
script
#!/usr/bin/env ruby
print "Enter your username: "
username = gets
puts "Here is your username: #{username}"
print "Enter your password: "
password = gets
puts "Here is your password: #{password}"
Then I fire up IRB and type:
ruby-1.9.2-p0 > pid, stdin, stdout, s...
Is there a reliable crossbrowser way to open up a shell using javascript (e.g. explorer.exe)?
...
This is the second time I've wanted to do this and again my google-fu has failed me.
When in the course of running a shell script (in my case a bash script) is there a program/script that tests whether the current shell supports color?
Alternatively is there a way to take the terminal type and easily determine if it supports color?
Ei...
I never studied OSes, so forgive me if this sounds basic or silly, but I'm curious about if one could replace the cmd prompt in Windows. I am NOT asking for programs that actually do this, as I've looked around and not really seen any.
What I'm asking is 1) if it's actually possible to write an entirely new program that would behave li...
Suppose I have a string like this:
blah=-Xms512m
I want the output as 512.
I know I can get it using grep on Linux like this:
echo $blah | grep -o -e [0-9]\\+
But this doesn't work on Solaris.
Any nice solutions so that it's compatible on both, Linux and Solaris?
Or atleast on Solaris?
...
In my bash script I execute some commands as other user.
I want to call a bash function in command of su I defined in my script before.
my_function()
{
do_something
}
su username -c "my_function"
The above script doesn't work, of course my_function is not defined inside su.
I have only the idea to save the function into separate fi...
I'm trying to create a script that will automatically backup a complete directory tree. I also want it to work for incremental backups. Basically, it wil work like this:
If file is in both source and destination and they are different, source file will be copied
If file is in both source and destination and they are the same, nothing w...
How can I execute a shell script from C in Linux?
...
I've written a shell script to soft-restart HAProxy (reverse proxy). Executing the script from the shell works. But I want a daemon to execute the script. That doens't work. system() returns 256. I have no clue what that might mean.
#!/bin/sh
# save previous state
mv /home/haproxy/haproxy.cfg /home/haproxy/haproxy.cfg.old
mv /var/run/ha...
Basically I want to do a program almost like a keylogger. The thing is that I as network admin sometimes I don't remember what I did to a machine on certain case, or same times I make howto's and tutorials for linux. I want to record what have i done.
So basically the idea of this program is:
you type the name of the program, (I call it...