Each element of a pipeline is executed in its own subshell and therefore cannot affect the parent shell.
Oh. How terribly inconvenient.
Oh, well. I may have stumbled upon a different solution:
If I have files "A A", "B B" and "C C", I'll get this result:
Now I can work with VAR like this:
I have a problem with the script below
#!/bin/sh
for vo in `find -maxdepth 1 -type f -regex "^\./*$"`
do
ls -l "$vo"
some other commands
done
It works fine until `find ...` returns files with spaces. I've tryed to change IFS but haven't succeed
Any solutions? (4 Replies)
I'm trying to do something like that:
for $filename in `ls -1`
do
some_command $filename
done
but it doesn't work properly for file names with spaces, for...in splits at spaces. Anyway around? (4 Replies)
I have files on my unix boxes that users have created with spaces.
Example: /tmp/project plan
ls -l "/tmp/project plan" works fine.
$/tmp>ls -l "/tmp/project plan"
-rw-r--r-- 1 root other 0 Jan 31 12:32 /tmp/project plan
I created a file called test and put just the... (2 Replies)
Hi All,
I see similar problems in past threads but so far no answers have worked for me. I am trying to write a script which parses a txt file that contains one filename per line, then finds those files on the local disk and copies them to a specified directory.
What I have:
... (4 Replies)
Hi,
i am very new to UNIX, i am trying to loop thru the files in a directory.
I got the filenames into a variable using
$files=`ls`
Here $files will contain
<filename1> <filename2> <filename3>
I want to get one filename at a time and append it to some some text.
forexample, ... (1 Reply)
Hi
I hope someone will be able to resolve this little teaser!
I am running a script
for file in `ls directory`
do
echo "$file"
...other code here....
done
this works fine unless we receive a file with a name which has a space in it
ie
"filena me"
(I know its not good... (8 Replies)
I want to ftp all the sh files in the directory. Also if any of the file name
contains spaces in them, it should be converted to underscores before it is ftped. I wrote the following code below:
FILESSH=$(ls /mysh/*.sh)
--- FILESH being used here for some other task ---
echo "$FILESSH" |... (3 Replies)
I have a problem mounting images because of the spaces in the filenames. Does anyone know how to rename files by removing the spaces with the find command?
find Desktop/$dir -name "*.dmg" -print -exec ??? (4 Replies)
Hello
I've got a certain no. of files in a directory whose names I'm reading and redirecting into a temporary text file using the command below:
ls -l | grep ^- | awk '{print $9}'However, whenever the file names contain spaces the above command considers only the part of the file name up to... (5 Replies)
I'm trying to handle some files with spaces in their name using "" or \ . Like "file 1" or file\ 1.
My current confusion can be expressed by the following shell script:
#!/bin/bash
touch "file 1" "file 2"
echo -n "ls: " ; ls
echo ---
for file in "file 1" "file 2" ; do
echo $file... (9 Replies)
Discussion started by: Ralph
9 Replies
LEARN ABOUT X11R4
upslog
UPSLOG(8) NUT Manual UPSLOG(8)NAME
upslog - UPS status logger
SYNOPSIS
upslog -h
upslog [OPTIONS]
DESCRIPTION
upslog is a daemon that will poll a UPS at periodic intervals, fetch the variables that interest you, format them, and write them to a
file.
The default format string includes variables that are supported by many common UPS models. See the description below to make your own.
OPTIONS -h
Display the help message.
-f format
Monitor the UPS using this format string. Be sure to enclose format in quotes so your shell doesn't split it up. Valid escapes within
this string are:
%%
Insert a single "%"
%TIME format%
Insert the time with strftime formatting
%ETIME%
Insert the number of seconds, ala time_t. This is now a 10 digit number.
%HOST%
insert the local hostname
%UPSHOST%
insert the host of the UPS being monitored
%PID%
insert the pid of upslog
%VAR varname%
insert the value of variable varname
The default format string is:
%TIME @Y@m@d @H@M@S% %VAR battery.charge% %VAR input.voltage%
%VAR ups.load% [%VAR ups.status%] %VAR ups.temperature%
%VAR input.frequency%
-i interval
Wait this many seconds between polls. This defaults to 30 seconds.
If you require tighter timing, you should write your own logger using the upsclient(3) library.
-l logfile
Store the results in this file.
You can use "-" for stdout, but upslog will remain in the foreground.
-s ups
Monitor this UPS. The format for this option is upsname[@hostname[:port]]. The default hostname is "localhost".
-u username
If started as root, upsmon will setuid(2) to the user id associated with username for security.
If username is not defined, it will use the value that was compiled into the program. This defaults to "nobody", which is less than
ideal.
SERVICE DELAYS
The interval value is merely the number given to sleep(3) after running through the format string. Therefore, a query will actually take
slightly longer than the interval, depending on the speed of your system.
LOG ROTATION
upslog writes its PID to upslog.pid, and will reopen the log file if you send it a SIGHUP. This allows it to keep running when the log is
rotated by an external program.
SEE ALSO
Server:
upsd(8)
Clients:
upsc(8), upscmd(8), upsrw(8), upsmon(8)
Internet resources:
The NUT (Network UPS Tools) home page: http://www.networkupstools.org/
Network UPS Tools 05/21/2012 UPSLOG(8)