unix

unix utility that reads files into memory?

I am using Ruby's net-ssh library to remotely execute shell commands. I would like to read a few files into memory rather than simply transfer them via SCP/SFTP. Can can I do this? ...

using sed to replace the contents of a file is not working in bash script

I have the following sed -e 's/<em\:update.*//g' install.rdf > install.rdf in a bash script, and it works on command line, but in the bash script install.rdf ends up a blank file. When I run sed -e 's/<em\:update.*//g' install.rdf > install.rdf command line, then 2 lines are stripped out of the file. Any idea why sed -e 's/<em\:update....

@ sign after a symbolic link directory in puTTy

in puTTy, what does the @ sign signify when it's right after a directory? ex. pdf/ public_html/ video@ It is a symbolic link, however on another server, the same symbolic link does not have an @ sign after it. ...

Trouble nesting expressions in UNIX.

I have the following UNIX statement: #!/bin/bash $x=$((grep ^'[a-z]' $1 | wc -l)) echo "$x" However, I'm getting an error message relating to a missing operand whenever I try to run the script. Is there any way to assign a variable a value like so in UNIX? EDIT: Well, it became clear to me that grep cannot seem to examine single wor...

How would I use grep on a single word in UNIX?

I want to run a script in unix that will look for a specific pattern inside a passed argument. The argument is a single word, in all cases. I cannot use grep, as grep only works on searching through files. Is there a better unix command out there that can help me? ...

UNIX "no match" error?

I'm trying to run the following: x=$(echo "$1" | egrep -c "^[0-9]|[:&^]") Now, this code is supposed to look for a word that starts with a number, or contains a :,& or ^. However,I geta "no match" error when I run this in UNIX. What makes matters more cofusing is that something similar runs well in terminal, but not in a script. ...

In UNIX what "cat file1 > file1 does?"

When the output of a command is redirected to a file, the output file is created or truncated by the shell before the command is executed, any idea what cat foo > foo does? ...

Unix Sed to get lines from a last occurance of a given word

I want to get the lines from a file from the line which contains the last occurance of a given word. Ex: True, there have been some changes in the plot. In the original, Kane tried to buy high political office for himself. In the new version, he just puts politicians on his payroll. If I give "In" then I need offic...

Best/conventional method of dealing with PATH on multiple UNIX environments

The main question here is: is there a standard method of writing UNIX shell scripts that will run on multiple UNIX platforms. For example, we have many hosts running different flavours of UNIX (Solaris, Linux) and at different versions all with slightly different file system layouts. Some hosts have whoami in /usr/local/gnu/bin/, and ...

Environment variables in symbolic links

Can we use $HOME or other environment variable in symbolic links? I know about using relative paths ../../.config but sometimes are to many ../ :) something like ~/.config would be more comfortable, or use of $HOME. Edit: habbie's answer with psmears's comment is the answer, sorry my question was incomplete. While (as other answers ...

Set umask for a sftp account?

Hi, Could anyone tell me how to set the umaskfor a single sftp user? Worth mentioning is a IBM AIX... Adding umask 002 to that user's .profile didn't work... (the goal is that this user files are accesible to people from the same group). I've seen somehowto's around editing the sftpd configs, though I want to set it for one user only,...

Copying a file to a directory that might not be writable by the application.

I am writing an application and I am at this point at the workflow: -File A doesn't exist? -Copy file B to file A -Error? -Copy file B to file A with higher privileges The problem is in the `Copy file B to file A with higher privileges' step. I am new to asking the admin for his/her password. I'd like a window similar to this, w...

UNIX: Strange output if piped to less

If I execute ls command with pipe to less, I get strange output ESC[00mESC[00mfile1.ccESC[00m ESC[00file2.ccESC[00m ESC[00file3.ccESC[00m (means ESC string in between). Without ls, the output is: file1.cc file2.cc file3.cc How to correct this? ...

Using the same file for stdin and stdout

I'm writing a application that acts like a filter: it reads input from a file (stdin), processes, and write output to another file (stdout). The input file is completely read before the application starts to write the output file. Since I'm using stdin and stdout, I can run is like this: $ ./myprog <file1.txt >file2.txt It works file...

What is '+' in the permissions field mean?

My professor needed access for copying my files and I used 'setfacl -b .' on my home directory to give him access. Now I changed it but now no one has access. So I then changed it so others can now have execute permission When I look at all the users on my server though, everyone seems to have "drwxrwx--x+" while mines is only "drwxrwx-...

Restoring ACL using setfacl/getfacl?

I recently removed my ACL because my professor needed to copy certain files. Now I know I should have just granted his user permissions instead of removing it all using 'setfacl -b .' on my home directory. So the question is how do I recover or set a new ACL to my home directory using setfacl/getfacl? ...

Mac Terminal: How to get faster screencaptures?

I've written the following script to help me get successive screencaptures. I'm able to get the screencaptures to happen in successive files, but not as fast as I'd like them. The sleep rate isn't recognized after a certain point. What are the decimal limits for 'sleep'? If it can in fact go lower, is there something wrong with my scri...

porting from linux to windows. mingw

I have a great problem with this porting building usual sdl is simple http://www.libsdl.org/extras/win32/mingw32/README.txt zlib libjpeg libpng giflib libtiff installing was hard but i did then SDL_image install was simple I took my sources from simple lerning project make clean && make g++ compile good at the linking stage hid very...

How to obtain total available disk space in Posix systems?

Hi! I'm writing a cross-platform application, and I need the total available disk space. For posix systems (Linux and Macos) I'm using statvfs. I created this C++ method: long OSSpecificPosix::getFreeDiskSpace(const char* absoluteFilePath) { struct statvfs buf; if (!statvfs(absoluteFilePath, &buf)) { unsigned long blksize, ...

mingw g++ cant see sdl-config

All works good if I insert sdl-config output manually. How to fix this bug? g++ -O3 -c 'sdl-config --cflags' test.cpp g++.exe: sdl-config --cflags: no such dile or directory ...