Sponsored Content
Top Forums Shell Programming and Scripting Reading multiple directories and file from them Post 302902086 by Klipeti on Sunday 18th of May 2014 12:02:58 PM
Old 05-18-2014
Reading multiple directories and file from them

Hello

I'm making script for Dallas temperature sensors (DS1820).

When a sensor is connected, it shows up as a directory in /sys/bus/w1/devices
in format 10-xxxxxxx. Inside the directory is a file called w1_slave which holds the temperature in format t=xxxxx.
Each sensor has unique 10-xxxxxxx directory.

I want to make script to go through all 10-xxxxxx folders and read the t=xxxxx from the w1_slave, then save it to file which is named like the directory of the sensor with current date: 10-xxxxxx_date.csv
Also, I use crontab to automatically run the script every 5 minutes, so I need to append new lines to the 10-xxxxxx_date.csv, not replace it!

I know how to read and save the t=xxxxx from w1_slave, but I don't know how to make script automatically go through all 10-xxxxxx folders!
Currently in my script I manually write the sensor's folder and manually write the file where the t=xxxxx is saved.
This is a problem, because what if one of the sensors must be changed or I want to use more or less sensors? I'd have to re-write many lines of the script!

Help is appreciated Smilie

Last edited by Klipeti; 05-18-2014 at 01:06 PM.. Reason: Forgot the mention detail
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy single file to multiple directories

Please help - I need to copy a single file to multiple directories. Dir structure: Parent_Directoy Filename1 Child_Directory1 Child_Directory2 Child_Directory3 Child_Directory4 .... So I need to copy Filename1 to all of the... (2 Replies)
Discussion started by: kthatch
2 Replies

2. UNIX for Dummies Questions & Answers

Clean directories by reading from file

I have a file in following format directory1=/out/log purgedays1=4 extn1=log,out,txt directory2=/clean/log purgedays2=4 extn2=log,out now i need need to create a script that reads this file and cleans all the files with the given extn from the given directory. The catch here is that... (2 Replies)
Discussion started by: max_payne1234
2 Replies

3. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

4. Shell Programming and Scripting

Multiple jobs reading from same file

I have a sequence of tasks that I routinely run and I'm trying to parallelize certain portions of the sequence. Specifically, there are 3 tasks which all read from the same file, each performing different operations and writing to their own seperate file. I was wondering if I could execute these... (3 Replies)
Discussion started by: erichpowell
3 Replies

5. UNIX for Dummies Questions & Answers

Deleting multiple directories inside multiple directories

Hi, Very unfamiliar with unix/linux stuff. Our admin is on vacation so, need help very quickly. I have directories (eg 40001, 40002, etc) that each have one subdirectory (01). Each subdir 01 has multiple subdirs (001, 002, 003, etc). They are same in each dir. I need to keep the top and... (7 Replies)
Discussion started by: kkouraus1
7 Replies

6. Shell Programming and Scripting

file name shortening for multiple directories

there was a post previously about this from around 2010 but i was unable to get the suggested scripts there to work. the following code works for me when it's saved inside the directory of files whose names i want to shorten, but i would like to be able to store it in a file with a list of ... (4 Replies)
Discussion started by: giseismology
4 Replies

7. UNIX for Dummies Questions & Answers

copy file using unix in multiple directories

Hi All Genious, I want to copy a file name XYZ .In a directory /HOME/dir/IXOS1/dir1 which contain multiple directories named not in pattern want to copy the XYZ in all of the directories available on path /HOME/dir/IXOS1/dir1 . Thanks in advance . (2 Replies)
Discussion started by: mumakhij
2 Replies

8. Shell Programming and Scripting

While loop reading file with multiple conditions

Hi Am trying to print the PIDs of process in a file and trying to grep any PID from that file I set the if condition as $value != "PID" and $value != "-" Assign that number to a variable Am confused since am using while loop to read the line from file and again if condition to check those... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

9. Shell Programming and Scripting

Help with create multiple directories under diff file systems

Hi, Need help ...I want to create multiple directories in different /file systems using for loop..eg.../ORCL_data01/oradata/orcl/ctl. ../ORCL_data01/oradata/orcl/data. ../ORCL_data01/oradata/orcl/redo. Script :- ========= for dir in `ls -d... (8 Replies)
Discussion started by: Linux6.5
8 Replies

10. Shell Programming and Scripting

Reading multiple lines in a file

Hello, I am new in shell scripting. I need help regarding following. I have 4 files generated by backups daily. I have stored the names of these 4 files into one file. i.e I have 4 files names as a, b, c & d and these names have been put into one file abcd.txt. Now I want to cat each file in... (7 Replies)
Discussion started by: Ali Sarwar
7 Replies
PSENSOR(1)							   User Commands							PSENSOR(1)

NAME
psensor - Temperature monitoring application SYNOPSIS
psensor [OPTION]... DESCRIPTION
psensor is a GTK application for monitoring hardware sensors, including temperatures and fan speeds. It displays a curve for each sensor, and uses Desktop Notification to raise an alarm when a temperature is too high. On Ubuntu an Applica- tion Indicator is also available, its icon changes when a temperature alert is raised. It can monitor: * the temperature of the motherboard and CPU sensors (using lm-sensors). * the temperature of the NVidia GPUs (using XNVCtrl). * the temperature and fan rotation speed of the ATI GPUs. * the temperature of the Hard Disk Drives (using hddtemp). * the rotation speed of the fans (using lm-sensors). * the sensors of a remote computer (using psensor-server). Psensor requires lm-sensors to be correctly installed and configured, it can be checked by running the command 'sensors'. If it has never be done, you may need to run the command 'sensors-detect' and follow the instruction. See the manpages of sensors(1) and sensors-detect(8) for more information. To retrieve the temperature of the Hard Disk Drives, the hddtemp daemon must be running. For remote monitoring: * start psensor-server(1) on the remote computer * run psensor with '--url' option: 'psensor --url=http://localhost:3131' ATI/AMD GPUs monitoring is available if the library libatiadlxx is present in the directory /usr/lib and psensor has been compiled with the ATI ADL SDK. Log is written to '$HOME/.psensor/log'. OPTIONS
-h, --help display this help and exit -v, --version display version information and exit -u, --url=URL the URL of the psensor-server, example: http://hostname:3131 -d, --debug=LEVEL set the debug level, integer between 0 and 3 REPORTING BUGS
Report bugs to: jeanfi@gmail.com psensor home page: <http://wpitchoune.net/psensor> COPYRIGHT
Copyright (C) 2010-2012 jeanfi@gmail.com License GPLv2: GNU GPL version 2 or later <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
psensor-server(1), sensors(1), sensors-detect(8), hddtemp(8) psensor 0.6.2.17 March 2012 PSENSOR(1)
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy