shell

symlink-copying a directory hierarchy

What's the simplest way on Linux to "copy" a directory hierarchy so that a new hierarchy of directories are created while all "files" are just symlinks pointing back to the actual files on the source hierarchy? 'cp -s' does not work recursively. Thanks! -Max ...

Linux: Move 1 million files into prefix-based created Folders

I have a directory called "images" filled with about one million images. Yep. I want to write a shell command to rename all of those images into the following format: original: filename.jpg new: /f/i/l/filename.jpg Any suggestions? Thanks, Dan ...

two folders in sync - one is updated with the CVS

I have copied a folder say "folder" which is maintained in CVS as folder_backup. $cp -af folder folder_backup Frequently I cvs update "folder" and I want folder_backup to be in sync with folder. Is there a automatic way to sync both folder and folder_backup whenever folder is cvs updated. Both are in the same machine. ...

How can I process this text file and parse what I need?

I'm trying to parse ouput from the Python doctest module and store it in an HTML file. I've got output similar to this: ********************************************************************** File "example.py", line 16, in __main__.factorial Failed example: [factorial(n) for n in range(6)] Expected: [0, 1, 2, 6, 24, 120] Got: ...

Portable command execution syntax implemented in Python

Python is not a pretty good language in defining a set of commands to run. Bash is. But Bash does not run naively on Windows. Background: I am trying to build a set of programs - with established dependency relationships between them - on mac/win/linux. Something like macports but should work on all the three platforms listed. This beg...

Why does subprocess.Popen() with shell=True work differently on Linux vs Windows?

When using subprocess.Popen(args, shell=True) to run "gcc --version" (just as an example), on Windows we get this: >>> from subprocess import Popen >>> Popen(['gcc', '--version'], shell=True) gcc (GCC) 3.4.5 (mingw-vista special r3) ... So it's nicely printing out the version as I expect. But on Linux we get this: >>> from subprocess...

find string inside a gzipped file in a folder

My current problem is that I have around 10 folders, which contain gzipped files (around on an average 5 each). This makes it 50 files to open and look at. Is there a simpler method to find out if a gzipped file inside a folder has a particular pattern or not? zcat ABC/myzippedfile1.txt.gz | grep "pattern match" zcat ABC/myzippedfile2....

Why is the following output produced by this SH script

Code: while read line; do tr 3 4 done<<EOF 1 2 3 4 EOF Produces: 2 4 4 Where does the 1 go? ...

git diff - external viewer - get all diff results

Hi, When external diff is configured, results are displayed per file, i.e. to view differences for the next file one needs to close currently running diff viewer. Is there a way to make git spawn all diff viewer processes in parallel? If I just spawn process from within external diff script, apparently git deletes the temporary files ...

Get common desktop path in .NET

I need to store files into the common desktop on Windows. The application is a very special application for exactly one special PC (device preparation), so it had to be easy for non-techie users to find and modify the configuration file. Now we switched to a domain, and because different people (with different accounts) should use the so...

writing a bash script that checks for a few special parameters before passing on the rest to another command

i am writing a bash script which acts as a wrapper around another command. it needs to be able to understand all of the parameters the command understands, plus a few extra. for example, if the command understands -abc switches and i wish for my wrapper script to understand those plus a -d and -e switch, then i need a way to look for and...

replace white spaces with a comma in a txt file in linux

Hi all, I need to edit few txt files (an output from sar) and to convert them into csv files. therefore I need to change every white space (or maybe it's a tab between the numbers in the output) using sed or awk functions (an easy shell script in linux) can anyone help me? every command I used didn't change the file at all (I tried gsu...

How to grab an arbitrary chunk from a file on unix/linux

I'm trying to copy a chunk from one binary file into a new file. I have the byte offset and length of the chunk I want to grab. I have tried using the dd utility, but this seems to read and discard the data up to the offset, rather than just seeking (I guess because dd is for copying/converting blocks of data). This makes it quite slow ...

korn Shell script to get files between two dates

Hi, Need to get the files between two given dates. If there are multiple files on one day get the latest of the files for that day. ...

korn shell script to get the most recent file for a given day

HI, I have a list of files from the last 7 days. From this list, if there are multiple files on a certain day, i need to get the latest for that day using korn shell script. Please help! ...

How to make zsh run as a login shell on Mac OS X (in iTerm)?

When zsh is set as a login shell on Mac OS X, when it is started by iTerm, zsh doesn't consider that it's being run as a login shell, although it's started as ‘-zsh’ (‘-’ is put as the first character of arg[0]) which is supposed to mean that it should start as a login shell. So, when I set the login shell to bash, bash recognizes this ...

How to execute the output of a command within the current shell?

Hi, I'm well aware of the source (aka .) utility, which will take the contents from a file and execute them within the current shell. Now, I'm transforming some text into shell commands, and then running them, as follows: $ ls | sed ... | sh ls is just a random example, the original text can be anything. sed too, just an example for...

What shell am I in?

If I'm in a shell script that has no shebang line… Hum, that doesn't matter, because indeed sh is always used. Maybe not so. Is there a command to identify the name/type of current shell, the path to the shell binary, and the version of the shell? I don't need all of that, but the more I can get, the better. I want something that has ...

7z and file flush. Its not compressing my file.

In encryptFile file if i change the if statement to true the code will work as expected. However i get console windows on screen which is ugly. When i make it false FileListName compress as empty archive. Why? using (TextWriter tw = (TextWriter)new StreamWriter( FileListName)) { writeFilename(tw, t, "."); ...

How do i launch files in C#

-Edit- I feel like an idiot. I had a feeling something like the answer below would work but didnt see any google results similar to the answers below. So when i saw this complex code i thought it had to be this way. I searched and found this http://stackoverflow.com/questions/24954/windows-list-and-launch-applications-associated-with-an...