Questions tagged [ls]

A utility in Unix-like systems such as Linux used for listing files and directories.

A utility in Unix and Unix-like operating systems used for listing files and directories. It is analogous to the dir command used in DOS and Windows.

Documentation

1314 questions
-2
votes
1 answer

sed can't read executable files when iterating in for loop

In a terminal shell, I am trying to loop over a set of Python files and perform find and replace with sed, e.g.: $ for f in `ls *.py`; do sed -i 's|foo|bar|g' $f; done; However, for some of the files (in particular just those Python scripts that…
Matt Pitkin
  • 3,989
  • 1
  • 18
  • 32
-2
votes
2 answers

How to get contents of a given "path" using 'ls -l' command and Python

I am using python and i want to get listing of all of the files /directories (not nested) at a given path. Meaning i need exact equivalent out put of "ls -l" command using python. For e.g. at path /opt/test/ ls -l out put is shown below. -rw-r--r-- …
Ammad
  • 4,031
  • 12
  • 39
  • 62
-2
votes
1 answer

Does ls -l print the file size in blocks or bytes?

I created a new file on a unix server. Now, ls -l prints the following: -rwxr-xr-x 1 mccorm14 student 49508 Oct 26 11:29 4th Does ls -l print the file size (49508) in blocks or bytes? If it is blocks, how do I convert it to bytes?
mccormick234
  • 21
  • 1
  • 3
-2
votes
3 answers

How to get latest occurrence of a file and sort by timestamp using AWK in unix

Below is the sample content of the hb_20190930103450.log file <------some lines-------> [2019-09-30 19:55:59] [MERGE] : ####### BEGIN - claim_response - '2016-01-15' - ####### <------some lines---------> [2019-09-30 20:17:11]…
dharani
  • 11
  • 2
-2
votes
2 answers

Linux List files dfference - "ls" vs "ls /"

Never used Linux before and trying to understand the difference between ls and ls / "ls /" gets all my dir (and more, but not .files - hidden files) as we can see it in this extensive list of commands. What about the ls?
user2060451
  • 2,576
  • 3
  • 24
  • 31
-2
votes
1 answer

How to list down the full paths to all files in multiple directories of a certain file format?

I am looking for a Bash solution to my dilemma here. I have directory project, and within that I have project/Batch1 project/Batch2 project/Batch3 and so on. Within each Batch folder, I have a mix of files but what I am interested in are files in…
Jared
  • 95
  • 1
  • 9
-2
votes
1 answer

How to find filenames from ls in a file in unix

I am trying to find if files in a directory, output of ls, exists in a file. So I have a file called test.txt inside this file I have few filenames like, V1.txt,v2.txt, v3.txt. Now when I do ls I find list of files in the directory, I want to…
-2
votes
5 answers

unix concatenate list of files into on line

In a directory, there is several files such as: file1 file2 file3 Is there a simple way to concatenate those files to get one line (connected by "OR") in bash as follows: file1 OR file2 OR file3 Or do I need to write a script for it?
Václav Struhár
  • 1,739
  • 13
  • 21
-2
votes
1 answer

Linux- ls If statement

I'm looking for an if statement. So when I run my script, it brings me a list of the backups with the date. The if statement is for, if there is no backup of the last 2 days echo "No recent backup". for when I ls -lrth: -rw-r--r--. 1 nfsnobody…
-2
votes
2 answers

Comparing two files based on size

I am facing difficulty in extracting the unique files of different sizes. Question: Inside a directory few files are present, suppose 2 files of 2 mb, 4 files of 4 mb and 3 files of 6 mb. Now, we need to run a script which will check all the files…
-2
votes
2 answers

How to list all the find -perm results?

I want to give a long list (with ls -l) of all the files in home directory that is writable by user, how can I combine find and ls -l?
-2
votes
1 answer

Stat not showing correct inode numbers

Trying to made my own ls command, using the stat structure to extract inode numbers of files, but continuous failure. here is my code: #include #include #include #include #include #include…
Ali Sajid
  • 3,964
  • 5
  • 18
  • 33
-2
votes
1 answer

How to expand ls -1 into a variable in Mac OSX terminal

Using the bash shell in the Mac OS X terminal, I want to put inside a variable all the filenames in the current directory, with one name per line (basically, the output of ls -1). However, if I do: var=$(ls -1) echo $var Variable 'var' contains…
user3781201
  • 1,261
  • 2
  • 9
  • 7
-2
votes
2 answers

What are the column heading for this "-rwxr-xr-x 1 root root 920788 Mar 28 2013 bash" when I do "ls -l" in the Ubuntu terminal

I executed the command "ls -l" in the ubuntu terminal, I understand the "ls -l" is the long listing in ubuntu, but I don't understand the columns for example: (This was the first line) -rwxr-xr-x 1 root root 920788 Mar 28 2013 bash How…
William Smith
  • 137
  • 2
  • 3
  • 11
-2
votes
1 answer

combine ls with grep and regex

In the /usr/bin folder on ubuntu 14.10, I try to search for files that start with the letter x. My command is : ls | grep ^x It doesn't work (no result) but I don't know why since ls x* return 162 results. After inspection, I think it comes from…
lovelace63
  • 352
  • 1
  • 6
  • 15