unix

How to learn work effectively with Unix CLI

Do you know any resources that teach to good habits of working in UNIX command line? EDIT: I don't mean general books about shell or man pages. I mean the things that you can only see watching professionals working with command line. For example when changing frequently between two directories they use "pushd" command, when repeating a...

Windows Mobile : Which icon is the application icon?

I am trying to write a unix command line utility that will extract the "application" icon from a Windows Mobile executable. When I look inside the .exe with wrestool from the icoutils package, I see multiple icon and group_icon resources. I am trying to figure out which icon the Windows Mobile Programs view would choose to display to t...

What's the Solaris equivalent to the BSD's 'tail -n100'?

I've looked this up a thousand times, and I always forget it, so, here for eternity: Solaris has a bit of an awkward syntax for tail. How do I do the equivalent of BSD's tail -nN? What I want are the last N lines from tail's input. ...

Unix shell: how to get the last lines of a file except the first 20?

Say I have a file with any number of lines, say, 125. I want to get all the lines except the first n, say, 20. So, I want lines 21-125. Is there a way to do this with with tail/head, or some other tool? ...

How do you use cat recursively?

Suppose I want to count the lines of code in a project. If all of the files are in the same directory I can execute: cat * | wc -l However, if there are sub-directories, this doesn't work. For this to work cat would have to have a recursive mode. I suspect this might be a job for xargs, but I wonder if there is a more elegant solution...

How to print the Nth column of a text file with AWK using argv

Suppose I have a text file with data separated by whitespace into columns. I want to write a little shell script which takes as input a filename and a number N and prints out only that column. With awk I can do the following: awk < /tmp/in '{print $2}' > /tmp/out This code prints out the second column. But how would one wrap that in...

xls to text converter

Anyone know of a free xls to text converter that can be run from the unix command line? ...

Compiling and Running java in Unix ( coming from Windows )

Ok, this is working on windows. My Java app is running and functioning normally javac -classpath .;ojdbc14.jar -g foo.java java -classpath .;ojdbc14.jar foo However, when I do the same thing on Unix I get this error: ojdbc14.jar: not found What am I doing wrong? I know the ";" is telling my shell that ojdbc14.jar is a new comma...

How to close a file descriptor from another process in unix systems

You can use command lsof to get file descriptors for all running processes, but what I would like to do is to close some of those descriptors without being inside that process. This can be done on Windows, so you can easily unblock some application. Is there any command or function for that? ...

How to warn for the use of unset variables in a korn shell script

Is there any way to throw errors or warnings in a korn shell script to prevent the use of unset variables ? Let's assume I have a temporary folder that I want to remove. TEMP_FILES_DIR='/app/myapp/tmp' rm -Rf $TEMP_FILE_DIR #notice the misspelling How to prevent this kind of mistakes before they actually happen? I know the script sh...

TextField "umlauts" are not shown on linux

Java 1.5, Linux I do have a screen which contains different textareas and textfields. I do have acess to the application frame, but not to the components inside the frame, because i only get an implementation of an interface. When i try to add german umlauts i see a rectangle in the text component, because the character is not supporte...

How can I get my bash script to work?

My bash script doesn't work the way I want it to: #!/bin/bash total="0" count="0" #FILE="$1" This is the easier way for FILE in $* do # Start processing all processable files while read line do if [[ "$line" =~ ^Total ]]; then tmp=$(echo $line | cut -d':' -f2) count=$(expr $count + 1)...

Does a function exist that searches the unix $PATH variable and returns true if a certain file exists?

The execvp() function executes the program that is given as an argument. It checks the $PATH variable to find the program. I'm writing something in which I would like to check to see if several programs exist before calling any exec() functions. What's the best way to do this? ...

Getting a unique id from a unix-like system

Hello. I want to get from any Unix-like system (if this is possible) a unique id that will be persistent every time my application runs in the same machine. If it is possible, I want to get the same id from Linux or FreeBSD or Solaris, etc... I don't want to generate a new id for each machine, but get an already existent id, and I prefe...

MySQL permissions issue - should be non-issue

This is making me kind of crazy: I did a mysqldump of a partitioned table on one server, moved the resulting SQL dump to another server, and attempted to run the insert. It fails, but I'm having difficulty figuring out why. Google and the MySQL forums and docs have not been much help. The failing query looks like this (truncated for ...

Includes with the Linux GCC Linker

I don't understand how GCC works under Linux. In a source file, when I do a: #include <math.h> Does the compiler extract the appropriate binary code and insert it into the compiled executable OR does the compiler insert a reference to an external binary file (a-la Windows DLL?) I guess a generic version of this question is: Is ther...

Unix: How to check permissions of a specific folder

So I'm learning Unix at the moment.... Now I know that using ls -l "directory/directory/filename" tells me the permissions of a file... how do I do the same on a folder? I could obviously use ls -l on the folder higher in the hierarchy and then just scroll till I find it but it's such a pain. If I use ls -l on the actual directory, it g...

Breaking out of "tail -f" that's being read by a "while read" loop in HP-UX

Hi All, I'm trying to write a (sh -bourne shell) script that processes lines as they are written to a file. I'm attempting to do this by feeding the output of tail -f into a while read loop. This tactic seems to be proper based on my research in Google as well as this question dealing with a similar issue, but using bash. From what I...

How do I get bash completion to work with aliases?

Case in point: I'm a on mac with bash v3.2.17, I'm using git installed via macports with the bash_completion variant. When I type git checkout m<tab>. for example, I get it completed to master. However, I've got an alias to git checkout, gco. When I type gco m<tab>, I don't get the branch name autocompleted. Ideally I'd like autocom...

How can I make my server have open connections to multiple clients at the same time?

I want to write my own little chat server in C on a MacOS machine. Now I want to connect to all clients, that are online and let the connection open, to be able to receive and send messages. The problem is that I only know, how to have one socket connection at a time open. So only one client can connect so far and chatting like that is k...