This is probably a very simple question to an experienced person with UNIX however I'm trying to extract a number from a string and keep getting the wrong result.
This is the string:
8962 ? 00:01:09 java
This it the output I want
8962
But for some reason I keep getting the same exact string back. This is what I've tried
pid=$(e...
How can I enable logging of all the commands entered in the tcsh shell?
I've tried:
Setting the $history variable to 100.
The $savehist to 99.
Set the $histfile to $home/.history
Typing commands into the shell doesn't save the commands in the history file.
...
Is it possible to name the full path to source directory in rsync command instead of the name of the module.
For example:
rsync -av rsync://10.171.73.23/home/user/work/tests .
instead of :
rsync -av rsync://10.171.73.23/ftp/work/tests .
(ftp is a module from /etc/rstncd.conf)
When trying the first version I get '@ERR...
How can I find a pid by name or full command line in Ruby, without calling an externally executable?
In my example below, I am sending a SIGUSR2 to a process who's command line contained "ruby job.rb". I would like to do the following without the call to pgrep:
uid = Process.uid
pid = `pgrep -f "ruby job.rb" -u #{uid}`.split("\n").firs...
I would like to remove multiple spaces in a file with a single character.
Example
cat kill rat
dog kill cat
I used the following regex, which seemed to matched in http://www.regexpal.com/ but wasn't working in sed.
([^ ])*([ ])*
I used the sed command like so:
sed s/\(\[\^\ \]\)*\(\[\ \]\)*/\$1\|/g < inputfile
I ...
So I got tired of waiting for Emacs to load every time anew, and consulting Emacs Wiki, I wrote me an invocation script such as:
#!/bin/bash
# @file: /usr/local/bin/emacs
# @version: 1
server=/tmp/emacs${UID}/server
if [ ! -S ${server} ] ; then
/opt/emacs/bin/emacs --daemon
until [ -S ${server} ] ; do
sleep 1s
done
...
Is there any way to find out the variables available in the scope of the shell script.
the scenario is like this, we are using some third party tools and we can customize the output with creating shell scripts with a particular naming convention. we know that certain parameters are being passed to our custom shell scripts but we want to...
Like many other people we're having line ending issues with CVS. However, unlike most our problem is the opposite.
Is there a way to force CVS to not convert lines from /n to CR/LF. I would like the line endings to remain in the Unix format even if I checkout to a Windows machine. Is that even possible?
The problem: the conversion of t...
I must embedd the shell of an interpreter language (most likely it will be python) inside my application. So i need a console widget in my GUI toolkit. I want to write this from ground up myself.
I know that i must start the process with pipes redirecting the standard input/output/error to my console widget. I have to set the environme...
So I have multiple files that I am working on and they need to be combined and sorted. Would it be more efficient to sort each file first and use the sort -m option when combining the files, or to combine them first and then sort.
Or is it the same? My understanding is that unix uses merge sort so in essence, would the one big file be ...
For my developer work I reside in the *nix shell environment pretty much all day, but still can't seem to memorize the name and argument specifics of programs I don't use daily. I wonder how other 'casual amnesiacs' handle this. Do you maintain an big cheat sheet? Do you rehearse the emacs shortcuts when you take your weekly shower? Or i...
I am trying to open a text file from an application run on UNIX using java.awt.Desktop 's open() method. If the file to be opened contains "From:" at its beginning, the API, fails by throwing an IOException.
Caused by: java.io.IOException: Failed to show URI:file:/filename.txt
at sun.awt.X11.XDesktopPeer.launch(XDesktopPeer.java:75)...
I'd like to convert ASCII code (like - or _ or . etc) in hexadecimal representation in Unix shell (without bc command), eg : - => %2d
any ideas ?
...
Hi
I started to write a terminal text editor, something like the first text editors in unix like vi. The only purpose is have a good and fun time, but I want to let in show text in color, so I could use it for edit source code. How could achieve this? There some POSIX special API for this, or I have to used ncurses (i don't want use it)...
Is there a standard way to make sure a python script will be interpreted by python2 and not python3? On my distro, I can use #!/usr/bin/env python2 as the shebang, but it seems not all distros ship "python2". I could explicitly call a specific version (eg. 2.6) of python, but that would rule out people who don't have that version.
It se...
Hi
I want to write a little script on my Mac. This script will basically look for new files in a particular folder, and move them to another location when some are found.
So I was about to write something very basic, with an infinite loop, and I was wondering if something a bit more nice already exist ? Like a Listener or something I ...
I'm going through the code of Unix version 6 with the Lion's book. One of the header files (param.h, can be accessed here) defines the following structs:
/*struct to access integers*/
/*single integer */
struct { int integ; };
/*in bytes*/
struct { char lobyte; char hibyte; };
These structures don't seem to define any instance, nor...
I have a tar.gz file about 13GB in size. It contains about 1.2 million documents. When I untar this all these files sit in one single directory & any reads from this directory takes ages. Is there any way I can split the files from the tar into multiple new folders?
e.g.: I would like to create new folders named [1,2,...] each having 10...
Here's what I want to do:
I have thousand of split rar archives on folder name Archives.
Name of the files 0001.part1.rar 0002.part2.rar 0003.part3.rar etc.
read 0001.part1.rar
create a directory based on prefix of the file above e.g. 0001
move all files with the same prefix on the directory created above.
Extract the files within ...
My desktop allows remote access. I work locally, sometimes other people log in, using ssh/telnet/ftp/rsh. Their processes get the same priority as my own.
I would like to set priority ('nice' value) of all processes for people logged in remotely to some higher value, e.g. 10. How can I do that?
I tried using pam_group to dynamically as...