Sponsored Content
Top Forums Shell Programming and Scripting Handling directory with spaces in for loops Post 302431287 by Scrutinizer on Monday 21st of June 2010 10:30:06 AM
Old 06-21-2010
Welcome to the forum, plmachiavel (as a member). Try using read, like so:
Code:
auditpath="/path/audited"
auditoutput="/export/home/XX/server_path_audited.txt"
find $auditpath -type d | grep -v .snapshot |
while read I 
do 
  tree=`echo "$I" | sed -e 's;[^/]*/;|____;g;s;____|; |;g'`
  group=`ls -ld "$I" | awk '{print " "$4}'`
  echo $tree" "$group
done

Quote:
Originally Posted by plmachiavel
I based my code on something I found somewhere (sorry, no originale credits )
Perderabo, perhaps?
https://www.unix.com/302170164-post2.html

Last edited by Scrutinizer; 06-21-2010 at 11:36 AM..
This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

handling spaces in unix

I am testing a ksh script for email. In the script I receive several parameters. One of them is a subject. The subject may contain spaces. Ex. Test this. When I am running the script on telnet to test, how should the syntax at the command line be written. I have this: ksh ResendE.sh '001111'... (2 Replies)
Discussion started by: supercbw
2 Replies

2. Shell Programming and Scripting

Directory names that contain spaces and other suggestions?

The script below was written to select files and convert a particular string to something other and replace that file. However, I came across some issues with filenames that contain spaces, any suggestions to get around this? Any other suggestions that may apply to this code would also be... (5 Replies)
Discussion started by: Shakey21
5 Replies

3. Shell Programming and Scripting

help in handling loops

Hi, I am using bash script I want some help in handling loops in my script... I need to check for a specific interval of time whether a file in a paritcular directory exists. If exists, i need to do some action and continue with the next iteration.. //my script attempt=0... (1 Reply)
Discussion started by: borncrazy
1 Replies

4. Shell Programming and Scripting

Mutiple For loops - moving files to another directory

I need to clean out some application subdirectories from backup scripts we used to rename to various backup extensions just in case the script failed in production and we need to rollback. I will be moving these old scripts to a staging directory and then removing them after 30 days (I have the... (9 Replies)
Discussion started by: tekster757
9 Replies

5. UNIX for Dummies Questions & Answers

How to access an directory with spaces

I am getting an error while trying to access a directory created with spaces in between, i couldn't able to login into that directory could you please suggest me what should i do to access that directory or if i want to rename that directory what should i do. Directory Name: MH PLR 2005... (1 Reply)
Discussion started by: Ariean
1 Replies

6. Shell Programming and Scripting

Handling blank spaces

Hi, I am trying to replace a specific column values in a csv file with double quotes when I am find embedded spaces with in the fields. Example: SNO,NAME,ZIPCODE,RANK,SEX,ADDRESS 1,Robert,74538,12,34, M,Robert Street, NY 2,Sam,07564,13,M,12 Main Ave, CA 3,Kim, Ed,12345,14,M,123D ,... (1 Reply)
Discussion started by: techmoris
1 Replies

7. UNIX for Dummies Questions & Answers

handling white spaces with getopt

Hi I'm trying to ensure that I have catered for all situations with my getopt cases. One other situation I want to cover is should the user enter the script without any preceding arguments eg: ./script_eg I need the script to the direct the user to the helpfile I have tried... (3 Replies)
Discussion started by: ladyAnne
3 Replies

8. UNIX for Advanced & Expert Users

File Processing: Handling spaces in a line

Hi All, Iam trying to get a file processed and some lines have spaces...the below is not working Want to remove empty line Want to remove lines that start with # Avoid line with substring WHOA When trying to get the substring from the var also Iam having trouble file is like VAR=VALUE,... (13 Replies)
Discussion started by: baanprog
13 Replies

9. Shell Programming and Scripting

Proper way to use a path with spaces in the directory name

I am using the below bash loop: or f in /media/cmccabe/My Book Western Digital/10_29and30_2015/*.bam ; do bname=`basename $f` pref=${bname%%.bam} samtools view -H $f | sed '/^@PG/d' | samtools reheader - $f > /home/cmccabe/Desktop/NGS/${pref}_newheader.bam done is the... (1 Reply)
Discussion started by: cmccabe
1 Replies

10. Shell Programming and Scripting

Handling filenames with spaces

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
i8kctl(1)							     Utilities								 i8kctl(1)

NAME
I8kctl, i8kfan - Utility to access SMM BIOS on Dell Inspiron laptops SYNTAX
i8kctl [<command> [<args>]] i8kfan [<left> [<right>]] DESCRIPTION
The i8kctl utility provides a command-line interface to the i8k kernel driver for Dell Inspiron laptops. When invoked without arguments the program reports the same information which can be read from the /proc/i8k file: 1. i8k format version 2. bios version 3. machine id 4. cpu temperature 5. left fan status 6. right fan status 7. left fan speed 8. right fan speed 9. ac power status 10. fn buttons status The optional command argument can be used to select only one of the above items. Command can be: version, bios, id, temp, fan, speed, ac and fn. Examples: $ i8kctl 1.0 A17 B5W123K 52 2 1 8040 6420 1 2 $ i8kctl temp 52 $ i8kctl fan 2 1 The fan command can accept two optional parameters which specify the new fan state for left and right fans. The state parameter can be: 0 turn the fan off 1 set low speed 2 set high speed - don't change the state of this fan For example the command: $ i8kctl fan - 2 sets the right fan to high speed and leaves the left unchanged. It should be noted that if the i8kmon(1) daemon is used to control the fans, setting the speed with i8kfan is pointless since the daemon will override the speed with its own value. Invoking i8kctl as i8kfan is the same as invoking the program with the fan option: $ i8kctl fan 1 2 1 2 $ i8kfan 1 2 1 2 FILES
/proc/i8k AUTHORS
Massimo Dal Zotto <dz@debian.org> COPYRIGHT
i8kctl and all the i8kutils programs , scripts and other files are distributed under the GNU General Public License (GPL). On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. SEE ALSO
i8kmon(1), i8kbuttons(1) Massimo Dal Zotto 18 March 2002 i8kctl(1)
All times are GMT -4. The time now is 12:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy