0
votes
1answer
75 views

I want to save events or logs grabbed using Inotify to a file

I need your help - using Inotify I am watching a directory for the changes like create, delete, rename and move. I want these event to be logged in a file and I want to run Inotify as a service.
1
vote
1answer
101 views

Error when using mv

I am receiving an error when trying to mv some files that really doesn't make sense. I receive this error: mv: cannot move `thatDir' to a subdirectory of itself, ...
2
votes
2answers
826 views

How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I ctrl+C the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It ...
0
votes
1answer
565 views

Sending a message to a remote terminal

Is there a way to send a message to a remote terminal similar to using the wall command for other users on the local system? In this scenario I want to specify a username@hostname and have a message ...
1
vote
2answers
2k views

How to encode the rdesktop password parameter in a shell script?

I can connect with this script from linux to a windows RDP session: #!/bin/bash /usr/bin/rdesktop -N -x m -u Administrator -p secret123 -d DOMAIN1 127.0.0.1:33891 (The rdp port of the remote ...
0
votes
2answers
1k views

How to concatenate environment variable paths in a cleaner way in bash?

In order to modify my paths (like LD_LIBRARY_PATH or PYTHONPATH), I first check is the variable exists. If so, I'm concatenating my old value with the new one (separated with a semicolon), else I'm ...
1
vote
1answer
265 views

Picking a single line from a text file by its line number

In a Unix shell, how can I pick a single line from a text file by its line number? Say I want whatever is at line 3 in animals.txt to be written to stdout (bat bat bat). monkey monkey monkey cat cat ...
3
votes
2answers
414 views

How do I prevent bash $ substitution?

I'm trying to preserve $if below and would like the following to output $if bash is getting in the way by doing $ substitution $ sed -e 's:\\$:\\$:g' <<ENDOFFILE > $if > ...
4
votes
1answer
1k views

Using a shell script to check if rsync made any changes

I've got a bash script that rsync's two directories. Sometimes there's a change, odds are there's nothing. I want to run a command only if rsync actually made a change (add/update a file). ...
4
votes
2answers
485 views

Shell scripting and regex: Which one is better to match numbers, [[:digit:]] or [0-9]?

As the title suggests, which one is better to match numbers, [[:digit:]] or [0-9]? I'm using the bash shell Thanks :)
0
votes
2answers
179 views

How do I traverse the filesystem looking for a regex match?

I know this is teeball for veteran sysadmins, but I'm looking to search a directory tree for file contents that match a regex (here, the word "Keyword"). I've gotten that far, but now I'm having ...
-2
votes
2answers
440 views

Run bash script with command line arguments

I want to do /usr/bin/bash myscript.sh -args which, as it stands, runs the script but doesn't pass the args to it. I realize that the conventional syntax is simply ./myscript.sh -args but I'm ...
1
vote
5answers
445 views

selective backup script in bash

I've been using this simple command (that's all I can do :) to backup the whole tree from my user data in NAS server for a year. cp -r /STORAGE /BACKUP-STORAGE/YYYY-MM-DD Unfortunately, after a ...
2
votes
2answers
1k views

How to change VGA mode after boot and login with ubuntu?

Is there a way to change the screen resolution of the console after the system has been booted? I've seen plenty on setting the vga= line in the boot and in the grub config but I'd like to be able to ...
0
votes
2answers
476 views

Bash & blocking processes

Could you help me with the Bash syntax to achieve the following? Run a blocking process without blocking execution of the rest of the script. Run a standard "non-blocking" process (e.g. lsof). ...
1
vote
5answers
979 views

bash script - print from line N to EOF

I want to be able to print the number of lines from bash as such: Line number (as counted from the top) -> end of the file It seems tail will only count lines from the bottom. Does anyone know how ...
5
votes
6answers
3k views

In *nix, how to determine which filesystem a particular file is on?

In a generic, modern unix environment (say, GNU/Linux, GNU/Solaris, or Mac OS X), is there a good way to determine which mountpoint and filesystem-type a particular absolute file path is on? I ...
5
votes
9answers
10k views

'Argument list too long' error while copying a large number of files

I am using the following command: \cp -uf /home/ftpuser1/public_html/ftparea/*.jpg /home/ftpuser2/public_html/ftparea/ And I am getting the error: -bash: /bin/cp: Argument list too long I have ...