I have one script that only writes data to stdout. I need to run it for multiple files and generate a different output file for each input file and I was wondering how to use find -exec for that. So I basically tried several variants of this (I replaced the script by cat just for testability purposes): but could not
Tag: unix
Advantage of $PATH over alias
I am relatively new to Linux and Unix. With the help of the internet I finally figured out how $PATH and aliases in my .bashrc work. But I really couldn’t find anything that describes when to use which. Let’s say I installed Python3.3 in Library/Frameworks and the executable is /Library/Frameworks/Python.framework/Versions/3.3/bin/python3, but I want to execute python 3.3 just by typing
How to remove setgid (linux/unix)?
I just changed my file permissions using $ sudo chmod g+s filename and my file permissions turned from drwxr-xr-x to drwxr-sr-x. How do I remove it? Answer Change the + for adding a permission into a – to remove it: If you want to do this programatically, you’ll need to use some bitwise operators. Normally it’s where S_ISUID is 0o4000,
Save argument ${1} passed to a shell script in a variable within shell script
I want to save ${1} argument passed to my script (${1} is a file path) into a string variable within the same shell script, and then echo the path using echo variable and not echo ${1}. Answer Simply try doing this :
Force write of a file to disk
I’m currently implementing a ping/pong buffering scheme to safely write a file to disk. I’m using C++/Boost on a Linux/CentOS machine. Now I’m facing the problem to force the actual write of the file to disk. Is it possible to do so irrespective of all the caching policies of the filesystem (ext3/ext4) / SO custom rules / RAID controller /
Shell script for remote SSH
I’m new to shell scripts, and I have centos running. I want to write a shell script that ssh a remote machine and execute a bunch of commands. The problem I’m facing is how to provide the username, the password, the remote machine address, and the private access key to a command that shall connect the remote machine. I’ve Google’d
what does $* mean in a shell script
What does $* exactly mean in a shell script? For example consider the following code snippet Answer It means all the arguments passed to the script or function, split by word. It is usually wrong and should be replaced by “$@”, which separates the arguments properly.
Track the time a command takes in UNIX/LINUX?
In UNIX/LINUX, is there an easy way to track the time a command takes? Answer Yes, use time <command>, such as Consult man time for more options. Link.
How to display only different rows using diff (bash)
How can I display only different rows using diff in a separate file? For example, the file number 1 contains the line: A file number 2 contains the following lines: How to make in the following happen? Answer a.txt: b.txt: Use comm: The command line options to comm are pretty straight-forward: -1 suppress column 1 (lines unique to FILE1) -2
logrotate configuration file development and testing
I have two questions related to developing configuration files for the logrotate tool on Linux systems. When I make a change to a file in /etc/logrotate.d, do I need to somehow notify logrotate so that it will recognize and respond to the change? It seems to notice changes on its own, eventually, but when testing log rotation specifications it would