Linked Questions
414 questions linked to/from Why *not* parse `ls` (and what to do instead)?
2
votes
2
answers
3k
views
Dealing with spaces of variables for `mv` [duplicate]
let's say I have a directory with the following files/directories:
google
apple
mozilla foundation # a file with spaces
browsers
So I would like to move files into browsers directory. Here is a ...
-2
votes
1
answer
7k
views
wc -c not working in a loop in the script [duplicate]
So I'm writing a simple script that checks if the size of the file is less than the given argument and if its true then its suppose to echo "YES"
#!bin/bash
Function ()
{
cd $1
lista=`ls`
...
1
vote
1
answer
3k
views
How to validate basic file information [duplicate]
I am trying to write a Bash script that takes the name of a file or directory as an argument and reports if the file is a directory, regular file or other. The script should also report if the user ...
0
votes
1
answer
530
views
Need help with ls and escape characters [duplicate]
I'm trying to create a bash script to run the ffmpeg command on every file in a directory with filenames that contain spaces. This is the script that I started with to do an individual file which ...
0
votes
1
answer
351
views
piping ls to other programs vs loop globbing [duplicate]
I am reading about the pitfalls of parsing ls and the examples given are about looping ls with for/while. The article title says 'parsing ls' - does that mean piping the output of ls to awk and other ...
0
votes
0
answers
292
views
What is wrong with parsing the ls command ? [duplicate]
I have been told that it is unwise to parse the output of LS due to security precautions.
The adage used was "parse sparsely and dont eat parsley"
I was attempting to count the amount of files ...
1
vote
3
answers
176
views
avoid spaces and apostrophes problems with ls in a awk script [duplicate]
I have many identical files in two (local) devices, and it happens that I have renamed some, only in one device (A). I found the following way to rename the identical files in the other device (B), ...
4
votes
0
answers
161
views
Why has ls never had a parsable option implemented? [duplicate]
So we all know you shouldn't parse ls for many reasons, mostly due to filenames allowing almost every character. However why has nobody been able to overcome this in an implementation of ls?
Many ...
933
votes
2
answers
2.4m
views
How do I make `ls` show file sizes in megabytes?
What commands do I need for Linux's ls to show the file size in MB?
293
votes
19
answers
205k
views
How can I grep in PDF files?
Is there a way to search PDF files using grep, without converting to text first in Ubuntu?
161
votes
10
answers
447k
views
How to output only file names (with spaces) in ls -Al?
I should echo only names of files or directories with this construction:
ls -Al | while read string
do
...
done
ls -Al output :
drwxr-xr-x 12 s162103 studs 12 march 28 12:49 personal ...
220
votes
8
answers
45k
views
Why is looping over find's output bad practice?
This question is inspired by
Why is using a shell loop to process text considered bad practice ?
I see these constructs
for file in `find . -type f -name ...`; do smth with ${file}; done
and
for ...
164
votes
9
answers
393k
views
List only regular files (but not directories) in current directory
I can use ls -ld */ to list all the directory entries in the current directory. Is there a similarly easy way to just list all the regular files in the current directory? I know I can use find
find . ...
115
votes
14
answers
269k
views
How do I count all the files recursively through directories
I want to see how many files are in subdirectories to find out where all the inode usage is on the system. Kind of like I would do this for space usage
du -sh /*
which will give me the space used in ...