unix

Move top 1000 lines from text file to a new file using Unix shell commands

I wish to copy the top 1000 lines in a text file containing more than 50 million entries, to another new file, and also delete these lines from the original file. Is there some way to do the same with a single shell command in Unix? ...

How do I find all the files that were create only today

How do I find all the files that were create only today and not in 24 hour period in unix/linux ...

What does the regular expression $$ mean?

what does the regular expression $$ evaluate to? ...

How to find encoding of a file in Unix via script(s)

Hi, I need to find the encoding of all files that are placed in a directory. Is there a way to find the encoding used? The file command is not able to do this. The encoding that is of interest to me is:ISO-8859-1. If the encoding is anythign else i want to move the file to another directory. Appreciate any assistance, Thanks, Manglu...

ruby: how to fire and forget a subprocess?

Hi, I have a long running process and I need it to launch another process (that will run for a good while too). I need to only start it, and then completely forget about it. I managed to do what I needed by scooping some code from the Programming Ruby book, but I'd like to find the best/right way, and understand what is going on. Here'...

How do you copy text from Firefox in Windows to bash shell in Unix?

I have a long URL on a web page in Windows that I need to copy into bash shell in Unix. Is there a way to do this without retyping the URL? ...

How to list non-empty subdirectories on linux?

I have a directory containing multiple subdirectories. I want to list only those subdirectories that contain at least one file. How can I do that? ...

Access a variable in a bash script

In the bash command line, I set a variable myPath=/home/user/dir . I created a script in which I put echo $myPath but it doesnt seem to work. It echoes nothing. What can I do to access the myPath variable in the script. If I write echo $myPath in the command, it works, but not in the script. ...

parse an email message for sender name in bash

I have multiple files in a folder and each of them have one email message. Each message has a header in the format Subject: formatting fonts To: [email protected] From: sender name message body I want to get all the unique sender names from all the messages (there is only 1 message per file) . How can I do that? ...

use space as a delimiter with cut command

I want to use space as a delimiter with the cut command. What would be the syntax? ...

In the bash shell, what is " 2>&1 "?

In a unix shell, if I want to combine stderr and stdout into the stdout stream for further manipulation, I can append the following on the end of my command: 2>&1 So, if I want to use "head" on the output from g++, I can do something like this: g++ lots_of_errors 2>&1 | head so I can see only the first few errors. I always have t...

In Unix, how do you remove everything in the current directory and below it?

I know this will delete everything in a subdirectory and below it: rm -rf <subdir-name> But how do you delete everything in the current directory as well as every subdirectory below it and the contents of all of those subdirectories? ...

BASH: Possible to abort shell script if any command returns a non-zero value?

I have a Bash shell script that invokes a number of commands. I would like to have the shell script automatically exit with a return value of 1 if any of the commands return a non-zero value. Is this possible without explicitly checking the result of each command? e.g. dosomething1 if [[ $? -ne 0 ]]; then exit 1 fi dosomething...

POSIX ACLs and the 'sticky' bit applied to a directory

POSIX.1e was going to define ACL (Access Control List) mechanisms for POSIX (amongst other security-related issues), but the proposals were never converted to a formal standard. Nevertheless, ACLs (not necessarily POSIX.1e ACLs) are supported at least optionally in all the main variants of Unix (Linux, BSD, MacOS X(ACL), HP-UX, AIX (p10...

how to get the command line args passed to a running process on unix/linux systems?

On SunOS there is pargs command that prints the command line aruguments passed to the running process. Is there is any similar command on other Unix environments? ...

Are there any small Unix or BSD distributions?

I was wondering if there are any small BSD or unix releases. The smallest Linux release I've seen that looked good is partedmagic (around 70MB). Free BSD needs like 4 CDs, maybe more. ...

disown a process in ksh

The "disown" command works in bash, but not in ksh. If I have started a process in ksh, how can I "disown" it, so I can exit my shell. (I know about nohup, but the process has already started!) ...

Command to find information about CPUs on a UNIX machine

Do you know if there is a UNIX command that will tell me what the CPU configuration for my Sun OS UNIX machine is? I am also trying to determine the memory configuration. Is there a UNIX command that will tell me that? ...

Is there an equivalent to WinAPI's MAX_PATH under linux/unix?

If I want to allocate a char array (in C) that is guaranteed to be large enough to hold any valid absolute path+filename, how big does it need to be. On Win32, there is the MAX_PATH define. What is the equivalent for Unix/linux? ...

What i need to install python 2.5 on SCO 5.0.5

I would love to install python2.5 on sco unix, and am wondering anybody who has attempted to do this? ...