unix

Need Linux cmd-line app to compare binary files and exit on 1st mis-match...

Is there a Linux command-line app which will compare two binary files and exit on the first mis-match? cmp doesn't seem to have the quit opition. ...

How to read output of sed into a variable.

I have variable which has value "abcd.txt". I want to store everything before the ".txt" in a second variable, replacing the ".txt" with ".log" I have no problem echoing the desired value: a="abcd.txt" echo $a | sed 's/.txt/.log/' But how do I get the value "abcd.log" into the second variable? Thanks, Roger ...

Problem redirecting output of find to a file

I am trying to put the result of a find command to a text file on a unix bash shell Using: find ~/* -name "*.txt" -print > list_of_txt_files.list However the list_of_txt_files.list stays empty and I have to kill the find to have it return the command prompt. I do have many txt files in my home directory Alternatively How do I save t...

How do I change my gdb path in Unix?

My professor posted this online for a lab this week, but I missed the tutorial and didn't find how to do this. Does anyone know? It is just a simple command line thing, but I have been hunting around and can't seem to figure it out... Hi everyone, A new version of gdb (version 6.8) has been installed on the servers csb and csg (but not...

Unix process synchronization without pthreads/sempahores, signals?

Hello, I am attempting to write a program that doesn't use pthreads or semaphore libraries. I want to do some synchronization with signals. I have read about them in a few Unix books, but I still don't quite get it. I wrote up some mock program design/code, this isn't my program but it gives an idea of how I am trying to organize process...

Getting file modification time on UNIX using utime in C.

I have been told by a professor that you can get a file's last modification time by using utime.h. However, the man page seem to cite that utime() only sets this value. How can I look up the last time a file was changed in C on a UNIX system? ...

From FreeBSD webhost, trying to connect to Access database on Windows through SSH2

My webhost is Pair.com, which runs FreeBSD. PHP is compiled with iODBC. I have SSH2 compiled and installed and tested. I can connect to the Windows machine through the firewall and get a directory listing. What I need is the incantation to open an Access database file through the SSH connection. (Very low-traffic site, so Access sho...

Passing output from one command as argument to another

Hello, I have this for: for i in `ls -1 access.log*`; do tail $i |awk {'print $4'} |cut -d: -f 1 |grep - $i > $i.output; done ls will give access.log, access.log.1, access.log.2 etc. tail will give me the last line of each file, which looks like: 192.168.1.23 - - [08/Oct/2010:14:05:04 +0300] etc. etc. etc awk+cut will extract the dat...

restriced key sort in unix

Hi , I have a file file1.txt with data: 2010/09/04,21:53:42.048,a 2010/09/04,21:53:40.923,b 2010/09/04,21:53:40.923,a 2010/09/04,21:50:42.048,a. I want to sort the file based on time stamp. I am currently using sort -t% -k1.1,1.23 file1.txt > file2.txt My expected output is 2010/09/04,21:50:42.048,a 2010/09/04,21:53:40.923,b ...

Convert hexadecimal to octet format

Hi, the ifconfig output of my machine is the following: :~ shell$ ifconfig en0 en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 00:25:bc:e7:39:6a inet6 fe80::225:bcff:fee7:396a%en0 prefixlen 64 scopeid 0x4 inet 10.170.133.45 netmask 0xffffff00 broadcast 10.170.133.255 media: autoselect (100...

Batch renaming files in unix and rollback

I rename few files (1234.xml, 9876.xml, 2345.xml etc) with .xml extension with the following code : for i in *.xml do mv $i $i.ab done it becomes 1234.xml.ab, 9876.xml.ab, 2345.xml.ab...etc Now, I want to rename it to 1234.xml.SD, 9876.xml.SD, 2345.xml.SD...etc. These are 100 files. How can this be achieved with the hel...

Create a function to check for key press in unix using ncurses

I have been looking for an equivalent to kbhit() and I have read several forums on this subject, and the majority seems to suggest using ncurses. How should I go about checking if a key is pressed in c++ using ncurses. The function getch() provided by ncurses reads character from the window. I would like to write a function that only c...

OS X script to send email when new file is created

How can I monitor a directory, and send an email whenever a new file is created? I currently have a script running daily which uses find to search for all files in a directory with a last modified date newer than an empty timestamp file: #!/bin/bash folderToWatch="/Path/to/files" files=files.$$ find $folderToWatch/* -newer timestamp -p...

How to make sed read the script from script file?

Recently I came across following grep command: /usr/xpg4/bin/grep -Ff grep.txt input.txt > output.txt which as per my understanding means that from input.txt, grep the matter contained in grep.txt and output it to output.txt. I want to do something similar for sed i.e. I want to keep the sed commands in a separate file (say sed.txt) ...

How to ignore program's output when using /usr/bin/time ?

I want to know how long a program running, so I tried "/usr/bin/time ./program > /dev/null". But soon I found it displays program's output to stderr. I tried "/usr/bin/time ./program > /dev/null 2>&1" then, but /usr/bin/time's output not appear. So my question is, how to ignore program's output, and keep time's output. Thanks a lot. ...

print all rows following matched row

How can I print all rows after matching pattern in nth row, but ignore all before matched row including the matching row, here is an example : row1 something in this row row2 something in this row row3 something in this row row4 don't need to match the whole line, something like java String.contains() row5 something in this row row6 som...

redirecting complete make output to a file

Hi I want to redirect complete make output to a file. I tried redirecting the stdout and stderr with the following command: make >aks_file.txt 2>&1 & But that is not redirecting the EXACT complete output which is otherwise generated by issuing just make (some lines are missing) Am I missing something? ...

How can I avoid 'make install' when building PHP in Unix environment?

I'm attempting to rapidly deploy a PHP application under apache2/PHP on a Unix host. The sysadmin hasn't heard of PHP so I'm looking to build/install myself. Unfortunately root access is two weeks of bureaucracy away so I'm looking for a way to use PHP and its requisite libxml2 without installing. ...

How does the *NIX GUI work?

I would like to know more about what makes the GUI on *NIX systems work, but not quite sure where to begin the research. From my understanding, the X server is what makes all the visuals possible, and atop that there are the various UI environments like KDE, Gnome and others. But, for instance, I have always thought that running under ...

How to create the empty 'Icon\r' file for a .dmg from shell script?

Hi, From shell script, I would like to create the empty 'Icon\r' file for a Mac OS X disk image (dmg), so as the .VolumeIcon.icns icon file is taken into account by the finder; the damn '\r' character is not accepted from the console: touch Icon\r ls Icon* > Iconr and other things happen when trying to type 'Icon\r', "Icon\r" etc., ...