unix

finding empty directories unix

i need to find empty directories for given list of directories some directories have directories inside it if inside directories also empty i can say main directory is empty otherwise it's not empty how can i test this for example A>A1(file1),A2 this is not empty beacuse of file1 B>B1(no file) this is empty C>C1,C2 this is empty ...

Unescpaing huge single-line string on Linux

I ended up with a huge, single line string literal (don't ask me how) where everything is escaped (mostly), including new lines and double quotes. Problem is, I want the original string. The string is huge so I'm not even sure how to begin. Here's what I have: "This\n is \"nice\",\nain\'t it?" This is what I want: This is "nice", ai...

running a program in Unix vs in Windows

I'm compiling a simple program written in C and I'm using Eclipse as an IDE, both in Windows 7 and on my MacBook Pro. Very simple program my friend wrote and asked me to help him with: int a = 0; char b[2]; printf("Input first class info:\n"); printf("Credit Hours: \n"); scanf("%d", &a); printf("Letter Grade: "); scanf("%s", b); So wh...

join 3 files by first Column with join (was awk) ?

i have three similar files, they are all like this: File A ID1 Value1a ID2 Value2a . . . IDN Value2n and i want an output like this Output ID1 Value1a Value1b Value1c ID2 Value2a Value2b Value2c ..... IDN ValueNa ValueNb ValueNc Looking to the first line, i want value1A to be the value of id1 in fileA, value1B the value of ...

How to make a command-line tool executable in OS X?

I just finished writing my very first command-line tool in Objective-C, compiled it, and now I'm curious about how one would go about making it executable as a command. For example, right now to use the program I have to type in ./filename -args into Terminal. I'd like to be able to only type in filename and execute the program. I tri...

RSync copies only folder directory structure not files

I am using RSync to copy tar balls to an external hard drive on a Windows XP machine. My files are tar.gz files (perms 600) in a directory (perms 711). However, when I do a dry-run, only the folders are returned, the files are ignored. I use RSync a lot, so I presume there is no issue with my installation. I have tried changing permi...

FTP to SFTP in shell scripting

This script is to connect to different servers and copy a file from a loaction defined. It is mandatory to use sftp and not ftp. #!/usr/bin/ksh -xvf Detail="jyotibo|snv4915|/tlmusr1/tlm/rt/jyotibo/JyotiBo/ jyotibo|snv4915|/tlmusr1/tlm/rt/jyotibo/JyotiBo/" password=Unix11! c_filename=import.log localpath1=`pwd` for i in $Detail ...

Build won't complete when launching Java from Hudson "Execute shell"

As part of deployment of an application, I use Hudson to launch the built application on a remote release server. This is done by specifying a post build step using the "Execute shell" option. I copy a deploy.sh script to the remote server and execute it via ssh, e.g. scp /opt/myapp/deploy.sh myapp@myserver:/export/home/myapp/scripts/ ...

Stacking standard output of `su`

I've got some code that I wrote that uses a combination of bash and PHP command line scripting. The script is ran as root and then uses su to become various uses. I start a session like this: $result = `su SomeUser ./dothis.php` Here ./dothis.php is a script that may generate some output being stored in $result, but the problem is tha...

system call to map memory to a file descriptor (inverse mmap)?

I want to be able to map memory to a file descriptor so I can use some existing functions that need a file descriptor. Here's essentially what I'm looking for: void do_operation1(int fd); char data[DATA_MAX] = { /* embedded binary data */ }; int fd = addr_to_fd(data, DATA_MAX); do_operation1(fd); /* ... operate on fd ... */ What sy...

How can i display seconds ago/minutes ago/with unix timestamp?

I need the unix timestamp - the timestamp i have. Then display the time between like on twitter. ...

How to extract files inside a directory from a tar file in terminal?

Hello, I want to extract only the files inside a folder of a tar file Example: Contents of tar file: /home/parent_dir/child_dir/ I want to extract only the files inside child_dir to another directory Thanks, SB ...

getting started with lex

I need to format some hexdump like this: 00010: 02 03 04 05 00020: 02 03 04 08 00030: 02 03 04 08 00010: 02 03 04 05 00020: 02 03 04 05 02 03 04 05 02 03 04 08 ‍ to 02 03 04 05 02 03 04 08 02 03 04 02 03 04 05 02 03 04 05 02 03 04 05 02 03 04 remove the address fields, if present remove any 08 at the end of a paragraph (followed ...

not able to use g++ from Fedora

$ yum list | grep gcc arm-gp2x-linux-gcc.i686 4.1.2-11.fc12 @fedora arm-gp2x-linux-gcc-c++.i686 4.1.2-11.fc12 @fedora gcc.i686 4.4.3-4.fc12 @updates libgcc.i686 4.4.3-4.fc12 @updates ...

setting codeigniter mysql datetime column to time() always sets it to 0

Hi guys. I'm using Codeigniter for a small project, and my model works correctly except for the dates. I have a column defined: created_at datetime not null and my model code includes in its array passed into db->insert: 'created_at' => time() This produces a datetime value of 0000-00-00 00:00:00. When I change it to: 'created_at...

How to list all users in a Linux group?

How do I list all members of a group in Linux (and possibly other unices)? ...

Unix tree convert to recursive php array

I have a response from remote server like this: /home/computer/Downloads |-- /home/computer/Downloads/Apple | `-- /home/computer/Downloads/Apple/Pad |-- /home/computer/Downloads/Empty_Folder `-- /home/computer/Downloads/Subfolder |-- /home/computer/Downloads/Subfolder/Empty `-- /home/computer/Downloads/Subfolder/SubSubFolder ...

Disk IO Performance Limitations based on numbers of folders/files

I have an application where users are allowed to upload images to the server. Our Web Server is a windows 2008 server and we have a site (images.mysite.com) that points to a shared drive on a unix box. The code used to do the uploading is C# 3.5. The system currently supports a workflow where after a threshold is met a new subfolder c...

What is the most robust way to determine the current codepage from a shell script?

Hi all, I'd like to determine the environment's current codepage at runtime from a Unix shell script. What's the most reliable way of doing this? I'm looking into parsing environment variable $LC_ALL, but it isn't always set to a useful value, and its format seems to vary (can be <locale>, or <locale>.<code page>, or <locale>.<code pag...

Editing Multiple files in vi with Wildcards

When using the programmers text editor vi, I'll often using a wildcard search to be lazy about the file I want to edit vi ThisIsAReallLongFi*.txt When this matches a single file it works great. However, if it matches multiple files vi does something weird. First, it opens the first file for editing Second, when I :wq out of the fil...