Sponsored Content
Top Forums UNIX for Advanced & Expert Users ls -ltr a list of filenames-with-spaces within a text file Post 302736593 by uschaafm on Tuesday 27th of November 2012 02:49:10 PM
Old 11-27-2012
[Solved] ls -ltr a list of filenames-with-spaces within a text file

OS: RHEL 5.8
shell: bash 3.2.25

Directory /home/guest/ contains these files:
file a
file b
file c
fileD
fileE
fileF
testFile.txt

I'm trying to find the syntax to run
Code:
ls -ltr

against this list of files that is contained within a text file, testFile.txt.

The file testFile.txt has the contents below, with file names within quotes and with files space delimited.

"/home/guest/file a" "/home/guest/file b" "/home/guest/file c" "/home/guest/fileF" "/home/guest/fileE" "/home/guest/fileD"

All attempts are failing upon encountering whitespace.
1.
Code:
ls -ltr `cat testFile.txt | xargs -0` 
 ls: "/home/guest/file: No such file or directory
 ls: a": No such file or directory
 ls: "/home/guest/file: No such file or directory
 ls: b": No such file or directory
 ls: "/home/guest/file: No such file or directory
 ls: c": No such file or directory
 ls: "/home/guest/fileF": No such file or directory
 ls: "/home/guest/fileE": No such file or directory
 ls: "/home/guest/fileD": No such file or directory

2. Same error from
Code:
ls -ltr `awk '{print}' /home/guest/testFile.txt

3. Same error from
Code:
cat testFile.txt | while read i ; do ls -ltr $i ; done

Any assistance would be greatly appreciated. Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

spaces in filenames

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)
Discussion started by: Hitori
4 Replies

2. UNIX for Dummies Questions & Answers

what does the ls -ltr command list

Hi, THe following is the output when i run the command ls -ltr can anyone explain the meaning of the field in red -rw-r----- 3 orca orca 20924 Sep 08 19:21 BTL027SASI.gnt -rw-r----- 3 orca orca 20924 Sep 08 19:21 BTL027RITD.gnt -rw-r----- 3 orca orca ... (2 Replies)
Discussion started by: ranjita.c
2 Replies

3. Shell Programming and Scripting

read list of filenames from text file, archive, and remove

I posted a week ago regarding this scripting question, but I need to revisit and have a few more questions answered.. User cfajohnson was extremely helpful with the archive script, but clarification on my part is needed to help steer the answer in a direction that works in this particular... (5 Replies)
Discussion started by: fxvisions
5 Replies

4. Shell Programming and Scripting

spaces in filenames, for do

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)
Discussion started by: naviztirf
4 Replies

5. Shell Programming and Scripting

How to list filenames with spaces in shell script

Hi, I want to list all the files matching in a directory directory given below Here one of the folder has a space in the path. /MAS02/RMS/WBDev/Krishna/Krishna Mohan/FMSplitByKeyAfterChanges1000075383.fileman.*.txt.out.1000075383.0 The following works from command line... (1 Reply)
Discussion started by: hikrishn
1 Replies

6. Shell Programming and Scripting

read list of filenames from text file and remove these files in multiple directories

I have a large list of filenames from an Excel sheet, which I then translate into a simple text file. I'd like to use this list, which contains various file extensions , to archive these files and then remove them recursively through multiple directories and subdirectories. So far, it looks like... (5 Replies)
Discussion started by: fxvisions
5 Replies

7. Shell Programming and Scripting

Adding specific text and spaces to each line in a text file

Hi, I wanted to add specific text to each row in a text file containing three rows. Example: 0 8 7 6 5 5 7 8 9 0 7 9 7 8 9 0 1 2 And I want to add a 21 at the beginning of the first row, and blank spaces at the beginning of the second two rows. To get this: 21 0 8 7 6 5 5 7 8... (4 Replies)
Discussion started by: hertingm
4 Replies

8. Shell Programming and Scripting

How to print the last column of the list contain filenames with spaces.

Hi experts, I have the following data: I want the last filed in the output. How to print the last field , It contains the file names and few filenames with white spaces . -rw-r--r-- 1 root root 0 2010-04-26 16:57 file1 2space_File.txt -rw-r--r-- 1 root root 0 2010-04-26... (2 Replies)
Discussion started by: rveri
2 Replies

9. Shell Programming and Scripting

I have two commands “ls -h” and “ls -ltr”. How do i make sure “ls -ltr” is run after “ls -h” is suc

help me (2 Replies)
Discussion started by: sonu pandey
2 Replies

10. Shell Programming and Scripting

Expanding a list of wildcard filenames with spaces

I think I must be missing something obvious but I have a file containing a list of files and paths, some with wildcard, others with spaces. e.g. /this/is/a/file /this/is/a/directory/ /this/is/a/collection/* /this/has spaces/in/it /this/had spaces/and/list/of/files*... (6 Replies)
Discussion started by: mij
6 Replies
REALMD.CONF(5)							   File Formats 						    REALMD.CONF(5)

NAME
realmd.conf - Tweak behavior of realmd CONFIGURATION FILE
realmd can be tweaked by network administrators to act in specific ways. This is done by placing settings in a /etc/realmd.conf. This file does not exist by default. The syntax of this file is the same as an INI file or Desktop Entry file. In general, settings in this file only apply at the point of joining a domain or realm. Once the realm has been setup the settings have no effect. You may choose to configure SSSD[1] or Winbind[2] directly. Only specify the settings you wish to override in the /etc/realmd.conf file. Settings not specified will be loaded from their packaged defaults. Only override the settings below. You may find other settings if you look through the realmd source code. However these are not guaranteed to remain stable. There are various sections in the config file. Some sections are global topic sections, and are listed below. Other sections are specific to a given realm. These realm specific sections should always contain the domain name in lower case as their section header. Examples of each setting is found below, including the header of the section it should be placed in. However in the resulting file only include each section once, and combine the various section setting together as lines underneath the section. For example [users] default-home = /home/%U default-shell = /bin/bash ACTIVE-DIRECTORY These options should go in an [active-directory] section of the /etc/realmd.conf file. Only specify the settings you wish to override. default-client Specify the default-client setting in order to control which client software is the preferred default for use with Active Directory. [active-directory] default-client = sssd # default-client = winbind The default setting for this is sssd which uses SSSD[1] as the Active Directory client. You can also specify winbind to use Samba Winbind[2]. Some callers of realmd such as the realm command line tool allow specifying which client software should be used. Others, such as GNOME Control Center, simplify choose the default. You can verify the preferred default client softawre by running the following command. The realm with the preferred client software will be listed first. $ realm discover domain.example.com domain.example.com configured: no server-software: active-directory client-software: sssd type: kerberos realm-name: AD.THEWALTER.LAN domain-name: ad.thewalter.lan domain.example.com configured: no server-software: active-directory client-software: winbind type: kerberos realm-name: AD.THEWALTER.LAN domain-name: ad.thewalter.lan os-name (see below) os-version Specify the os-name and/or os-version settings to control the values that are placed in the computer account operatingSystem and operatingSystemVersion attributes. This is an Active Directory specific option. [active-directory] os-name = Gentoo Linux os-version = 9.9.9.9.9 SERVICE
These options should go in an [service] section of the /etc/realmd.conf file. Only specify the settings you wish to override. automatic-install Set this to no to disable automatic installation of packages via package-kit. [service] automatic-install = no # automatic-install = yes USERS
These options should go in an [users] section of the /etc/realmd.conf file. Only specify the settings you wish to override. default-home Specify the default-home setting in order to control how to set the home directory for accounts that have no home directory explicitly set. [users] default-home = /home/%D/%U # default-home = /nfs/home/%D-%U The default setting for this is /home/%D/%U. The %D format is replaced by the domain name. The %U format is replaced by the user name. You can verify the home directory for a user by running the following command. $ getent passwd 'DOMAIN/User' DOMAINuser:*:13445:13446:Name:/home/DOMAIN/user:/bin/bash Note that in the case of IPA domains, most users already have a home directory configured in the domain. Therefore this configuration setting may rarely show through. default-shell Specify the default-shell setting in order to control how to set the Unix shell for accounts that have no shell explicitly set. [users] default-shell = /bin/bash # default-shell = /bin/sh The default setting for this is /bin/bash shell. The shell should be a valid shell if you expect the domain users be able to log in. For example it should exist in the /etc/shells file. You can verify the shell for a user by running the following command. $ getent passwd 'DOMAIN/User' DOMAINuser:*:13445:13446:Name:/home/DOMAIN/user:/bin/bash Note that in the case of IPA domains, most users already have a shell configured in the domain. Therefore this configuration setting may rarely show through. REALM SPECIFIC SETTINGS
These options should go in an section with the same name as the realm in the /etc/realmd.conf file. For example for the domain.example.com domain the section would be called [domain.example.com]. To figure out the canonical name for a realm use the realm command: $ realm discover --name DOMAIN.example.com domain.example.com ... Only specify the settings you wish to override. computer-ou Specify this option to create directory computer accounts in a location other than the default. This currently only works with Active Directory domains. [domain.example.com] computer-ou = OU=Linux Computers,DC=domain,DC=example,DC=com # computer-ou = OU=Linux Computers, Specify the OU as an LDAP DN. It can be relative to the Root DSE, or a complete LDAP DN. Obviously the OU must exist in the directory. It is also possible to use the --computer-ou argument of the realm command to create a computer account at a specific OU. user-prinicpal Set the user-prinicpal to yes to create userPrincipalName attributes for the computer account in the realm, in the form host/computer@REALM [domain.example.com] user-principal = yes automatic-id-mapping This option is on by default for Active Directory realms. Turn it off to use UID and GID information stored in the directory (as-per RFC2307) rather than automatically generating UID and GID numbers. This option only makes sense for Active Directory realms. [domain.example.com] automatic-id-mapping = no # automatic-id-mapping = yes manage-system This option is on by default. Normally joining a realm affects many aspects of the configuration and management of the system. Turning this off limits the interaction with the realm or domain to authentication and identity. [domain.example.com] manage-system = no # manage-system = yes When this option is turned on realmd defaults to using domain policy to control who can log into this machine. Further adjustments to login policy can be made with the realm permit command. fully-qualified-names This option is on by default. If turned off then realm user and group names are not qualified their name. This may cause them to conflict with local user and group names. [domain.example.com] fully-qualified-names = no # fully-qualified-names = yes AUTHOR
Stef Walter <stef@thewalter.net> Maintainer NOTES
1. SSSD https://fedorahosted.org/sssd/ 2. Winbind http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/winbind.html realmd 06/10/2014 REALMD.CONF(5)
All times are GMT -4. The time now is 08:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy