Tagged Questions
4
votes
4answers
69 views
linux + how to ignore (filter) file with space
Sometimes a file name is created from a couple of names and space between each name as the following:
$ touch "A B C"
$ ls
A B C <-- one file but has three words ! ...
5
votes
4answers
137 views
Show sum of file sizes in directory listing
The Windows dir directory listing command has a line at the end showing the total amount of space taken up by the files listed. For example, dir *.exe shows all the .exe files in the current ...
1
vote
2answers
166 views
Ignore all matches to negated extglob pattern in recursive ls
I would like to recursively list all files in a directory which match a given input pattern using ls. (Oh, and this is in Bash).
The only way I can think of to do this using ls is to shopt -s extglob ...
2
votes
2answers
387 views
list all files newer than given timestamp and sort them
I want to list all files (sorted by date) that are newer than timestamp in format 20130207003851 in directory /tmp only. Subdirectories can be omitted.
Using SUSE Linux Enterprise Server 11.
The ...
0
votes
1answer
162 views
difficalty to save traceroute output in shell variable?
I need to filter and store traceroute output in shell variable (array). But I am getting some unusual output.
As I try to explain in following lines.
My present directory is temp, having some ...
1
vote
2answers
232 views
List info about files/directories with spaces
I am trying to use ls to get information about files and directories. My current command fails to properly get the name whenever a file/directory has a space.
I am using this to list all ...
3
votes
2answers
754 views
How to solve sudo: unable to execute /bin/ls: Argument list too long
When I run this command from php
sudo -u db2inst1 ls -t /var/lib/edumate/bdrs/*/*/daily/*NODE* | sort -r
I receive sudo: unable to execute /bin/ls: Argument list too long
ls lists all daily backup ...
2
votes
1answer
1k views
How to get exact file size and file name?
Right now I am using ls -lt /my/directory (see below) then php parses the output. But inconsistently because the delimiter is space and there might be two or more spaces in between two fields.
The ...
2
votes
3answers
426 views
Can I list only specific subdirectories?
I have a folder tree structure like
arndell
\_databases
\_daily
\_weekly
claremont
\_databases
\_daily
\_weekly
monte
\_databases
\_daily
\_weekly
and I am only after all files inside ...
2
votes
3answers
2k views
How to search and replace text in all php-files in a directory and it's subdirectories
I am looking for a shell script that recursively traverses all .php files in a directory and performs a search & replace of a particular text pattern.
The search pattern is quite long ( > 5000 ...
-2
votes
1answer
196 views
Why does this script show all files in the directory and not just PDF files?
I wrote the script below to find the number of PDF files in a given directory. However, it instead shows all the files in the directory:
#!bin/bash
message="."
message1="*.pdf"
ls -al $message ...
13
votes
3answers
325 views
When does `ls -s` print “0”
Of course, the standard way of testing if a file is empty is with test -s FILE, but one of our clients have received a script containing tests like this:
RETVAL=`ls -s ./log/cr_trig.log | awk '{print ...
4
votes
2answers
319 views
How to list files and directories with directories first
I have two questions. First, which command lists files and directories, but lists directories first?
Second question: I want to copy a list of files into a single directory, but make the target ...
5
votes
6answers
2k views
Compare files that are in directory 1 but not directory 2?
I'm having trouble with a bash script I want to make
I know ls will list files that are in a directory but I want it to list directories that are in directory1 but NOT in directory2, and then list ...
8
votes
3answers
4k views
Find the owner of a directory or file, but only return that and nothing else
I am looking for a command that will return the owner of a directory and only that--such as a regex parsing the ls -lat command or something similar? I want to use the result in another script.