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
XEN-RESIZE-GUEST(8)					 Perl Programmers Reference Guide				       XEN-RESIZE-GUEST(8)

NAME
xen-resize-guest - Resize a loopback or LVM based xen guest. SYNOPSIS
xen-resize-guest [options] Help Options: --help Show help information. --manual Read the manual for this script. --version Show the version information and exit. --verbose Show diagnostic output. General Options: --add Specify the amount of space to add, e.g. --add=1gb --dir Specify the path to the loopback image root. --force Force the resize to happen without a last-chance delay. --hostname Specify the hostname of the guest to resize. OPTIONS
--add Specify the amount of storage to add to the primary disk. --dir Specify the directory where the loopback files are based. --force Don't pause for 10 seconds prior to commencing. --help Show help information. --hostname Specify the hostname to delete. --lvm Specify the volume group to use. --manual Read the manual for this script. --version Show the version number and exit. DESCRIPTION
This tool will ease the resizing of Xen guests, whether they are based upon loopback files or LVM partitions. Whilst the process of resizing a guest is pretty simple it can be fiddly to do the steps correctly in the right order: 1. Shutdown the guest. 2. Unmount the volume, if it is mounted. 3. Add to the space. 4. Check the filesystem. 5. Resize the filesystem. 6. Restart the guest. More than once I've heard of users making mistakes and breaking their filesystems; hence this tool. AUTHORS
Steve Kemp, http://www.steve.org.uk/ Axel Beckert, http://noone.org/abe/ LICENSE
Copyright (c) 2005-2009 by Steve Kemp, (c) 2010 by The Xen-Tools Development Team. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license. 4.3.1 2012-06-30 XEN-RESIZE-GUEST(8)
All times are GMT -4. The time now is 09:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy