Questions tagged [ls]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
7 views

In Ubuntu command ls -l with jc of kellyjonbrazil dosn´t work correct

I try to convert the ls -l command with jc (from js) in a json-object. ls -l | jc --ls -p Unfortunate I get this output: wrong output But according to docs from Developer (docs the output must be ...
  • 1
2 votes
3 answers
65 views

Is there a more efficient way to locate backup directories and save the formatted list to a file?

I have an Ansible playbook to perform the following task: Access a remote host via ssh and create a text file that lists all the backups on the remote host filesystem that can be inserted into an ...
  • 23
0 votes
1 answer
32 views

Problem with custom recurrent version of ls command

I have no idea why the example from Learning the Bash shell does not work. It is supposed to be recursive variant of ls command. What it does is printing only the name of directory and that's all. Any ...
-2 votes
1 answer
43 views

Why is the ls command with a wildcard only returning the first match when run within a script?

The directory contents: newfile1 newfile2 oldfile1 oldfile2 my script arg="${1}" ls "${arg}" Input is newfile* The output newfile1 Expected output newfile1 newfile2 Why don't I ...
0 votes
2 answers
41 views

Unix command to list files as per string pattern preference in file name

Need to list and copy files as per pattern preference in file name- There are 5 log files patterns are getting generated on every run and I want to copy the longest pattern match file first and give ...
0 votes
1 answer
32 views

How to list number of lines inside each file listed by the ls command?

I am using the bash ls command as follows: ls -S -l *usc*.vhd This lists all the files that have the letters usc in its name and ends with .vhd extension. Now, I also need the output to print how ...
  • 2,388
0 votes
1 answer
14 views

how to exclude specific symbols from ls output in command line?

for example I have list of pdfs: 01_name1.pdf 02_name2.pdf 03_name3.pdf 04_name4.pdf 05_name5.pdf 06_name6.pdf 07_name7.pdf how do I get this output from command line: name1 name2 name3 name4 name5 ...
-2 votes
1 answer
52 views

Difference between ls -a and ls -alps

I don't understand the difference between ls -a and -alps. I can see the result is different but I'm not sure why its display is different. More specifically I don't really know -alps does. it does ...
  • 33
-1 votes
2 answers
133 views

Use of ls -la on windows OS [duplicate]

software devs it is requested to help me. I want to use the ls -la command on the vs code terminal. It is not working enter image description here I tried setting the execution policy to unrestricted. ...
  • 9
0 votes
1 answer
78 views

Two pipe in C and ls | sort | grep r [duplicate]

I need to create a program that execute in the shell this command with two pipes and three process: ls | sort | grep r. The code I have done is this: #include <stdio.h> #include <stdlib.h> ...
  • 1
0 votes
1 answer
66 views

Listing directories with tab as delimiter

When we list files in unix using ls -l command the output is a table with space as a separator, for example the following (jupyter-lab) ➜ mylab ls -l total 2 drwxr-sr-x. 2 hs0424 ragr 0 Feb 1 12:17 ...
0 votes
0 answers
11 views

How to recursively list (ls) a symbolically linked directory on the Mac terminal

I want to list all directories and subdirectories in a folder on my Mac (OS Catalina) using terminal. One of the directories is a symbolically linked directory (alias). ls -R works fine but doesn't ...
  • 231
1 vote
4 answers
127 views

Get an array of all files in a remote folder using SSH in BASH

I'm trying to get an array of all files in a remote folder using bash and SSH: declare -a existing_files=$(ssh -q -i $SSH_KEY_PATH -t $PROXY_SERVER \ ssh -q -i ubuntu_vm $REMOTE_SERVER "ls $...
0 votes
2 answers
50 views

realloc fails when printf is in code / weird chars

I try to program a simple implementation of ls for school #include <dirent.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> int ...
  • 185
0 votes
0 answers
33 views

How to watch the output of ls with wildcards in bash, displaying the output in columns

Using bash, I am trying to write a command (for my bashrc) that updates the output of ls every 2 s, displaying the output in columns (rather than one item per line). I have a command that works, but ...
0 votes
0 answers
52 views

No var directory?

I know this is probably the dumbest question ever, but I just started coding and can't even get past the first lesson. So many things depend on the "var" directory, but I can't find it ...
  • 1
0 votes
0 answers
23 views

Can not find physical file downloaded by wget

I am new to Google Colab. I tried to get some CSV data and put them into folder. Here is what I do : Mount the drive from google.colab import drive drive.mount('/content/drive') Get the file : !...
0 votes
1 answer
48 views

Bash list files as {path + file}

I want to search for a file that has 1033 bytes of size. Therefore, I write ls -lRA, which outputs around 200 files, in around 20 folders. When I grep for the file with ls -lRA | grep 1033 I get one ...
0 votes
1 answer
46 views

Why does the ls instruction in gitbash not show me my c drive?

iamth@DESKTOP-TQE8AEJ MINGQ64 ~ (master) $ cd .. iamth@DESKTOP-TQE8AEJ MINGQ64 /c/Users $ cd ../.. iamth@DESKTOP-TQE8AEJ MINGQ64 / $ ls LICENSE.txt cmd/ git-bash.exe* proc/ unins000....
1 vote
1 answer
102 views

How to convert images with parallel from one directory to another

I am trying to use the following command: ls -1d a/*.jpg | parallel convert -resize 300x300 {}'{=s/\..*//=}'.png However one problem that I didn't succeed to solve is to have the files to be output ...
0 votes
0 answers
15 views

How to simple Regex with ls

I'd like to list contents of several folders in one line. ie /etc/dovecot/keys and /etc/postfix/keys and I'm not sure how to use Regex. I came as far as doing the following: ls /etc/[d,p]*/keys ...
  • 173
-1 votes
2 answers
58 views

Implementing parsing with the ls command in C

I'm trying to implement the ls command in C with a few parameters like -a, -l... or -la, but I'm having issues with the parsing, when I use the input I get Segmentation Fault, this is an example of ...
0 votes
0 answers
34 views

List a directory with SSH inside SSH

I need to list the contents of a directory that is on another server in a single line of code. For that, I need to connect to a server and, from this server, I need to go to the final server, via SSH. ...
0 votes
1 answer
73 views

ls doesn't produce the same output from Linux to MacOs

I am rewriting my own implementation of ls and I have found out that it doesn't work the same on my Macbook and my Xubuntu virtual machine. The behavior I am testing is the use of a flag after the ...
  • 103
0 votes
0 answers
30 views

Sort output from ls command is not alphabetically

ls sort alphabetically char - ascii is 45 char 9 ascii is 57 so file - sort before 9 but why file 999-a sort after 9999a $ ls -1 - 9 9999a 999-a
2 votes
1 answer
272 views

Command works in shell but not in a script [duplicate]

I'm using the command ls files/@(*.text|*.txt|*.xt) to get all files that end with any of the patterns. When I run it in the shell I get this result $ ls files/@(*.text|*.txt|*.xt) files/f1.text ...
0 votes
0 answers
96 views

com.jcraft.jsch.sftpException: java.io.IOException: pipe closed at com.jcraft.jsch.ChannelSftp.ls(Channelsftp.java)- [jsch-0.1.65.jar:0.1.65]

I am trying to transfer one file from one server to another server, I have done recursive file and folder transfer from one server to another server. it working for lower environment but it is failing ...
  • 1
2 votes
4 answers
413 views

get files from directory in bash and build JSON object using jq

I am trying to build list of JSON objects with the files in a particular directory. I am looping thru the files and creating the expected output object as string. I am sure there is a better way of ...
  • 11.1k
1 vote
2 answers
57 views

Why does ls not subset by filetype recursively (with -R)?

I want to list all .jpg files in all subdirectories using ls. For the same directory this works fine: ls *.jpg However, when using the -R for recursiveness: ls -R *.jpg I get: zsh:no matches found: *....
  • 88
0 votes
1 answer
56 views

Surprising GREP Behavior [closed]

I have a directory that contains the following Applications Desktop Documents Downloads Dropbox (Personal) Google Drive Library Movies Music Pictures Public I am trying to learn how ...
  • 1,816
-1 votes
1 answer
93 views

cp: cannot stat 'ls -l ~/ | grep ^.r\w\-': No such file or directory - error

I have been trying to copy all files with read/write permissions for owners from the home directory to another directory but I've been facing this problem as in the title. Any help? subDir=`date '+%y%...
  • 1
-2 votes
1 answer
28 views

Linux bash - Regular Expression to find a string included between a static string and the first number

I need to extract in linux bash from a string a set of characters which are included between a static string and the first number. A simple example should be helpful: Base string: hello-world-my_name-...
-1 votes
1 answer
4k views

bash: /usr/bin/ls: cannot execute binary file: Exec format error

I am using a web terminal ubuntu 20.04 to learn shell and everything was working fine. suddenly I started getting this error message when I invoked the ls command when I tried listing my current ...
-1 votes
1 answer
94 views

Find and delete directories except last 4 modified ones in linux [closed]

To delete all the directories inside a folder except the last 4 modified folders in Linux, does the below command work? find /path/folder -mindepth 1 -maxdepth 1 -type d | xargs ls -td -- | tail -n +5 ...
  • 11
0 votes
1 answer
54 views

Is this possible in this command to cd into the directory thats printed in output

When I do ls | grep -e *-folder1 it prints my-folder1 that's the name of the folder matched in the command in current directory. Is there a way I can add something like cd into this directory. This is ...
  • 3,734
-3 votes
1 answer
51 views

Command ls - A $path doesn't see desktop directory as empty. How come?

if [ "$(ls -A $path)" ];then echo $path dirpath = "$mainPath/$path" fi
0 votes
0 answers
62 views

How to print out the result of ls command in Makefile?

I am writing a Makefile to automate the daily task. In the Make file, I have some targets and dependencies. In this scenario, ls lists down 2 files. Command: ls home/user/* Result: File_A File_B This ...
  • 1
0 votes
1 answer
568 views

ls: cannot access '<DIR PATH passed by pipe>': No such file or directory

I have a set of directories of my interest that I want to do sed and grep on files under only these directories. What I did is that I put all the paths in txt file, all paths are put between "&...
  • 3
-2 votes
1 answer
3k views

In termux android ls: cannot open directory '.': Permission denied?

enter image description here '''ls: cannot open directory '.': Permission denied'''
0 votes
1 answer
45 views

I get an error when I am try using -ls with different directory. And I don't know why

I am using -ls to check if my files exist. The problem is when I run this: infile=/Volumes/malrosie/data/satellite/chlor_a/cmems/mapped/4km/daily/*.nc ls -l $infile | tail -n 1 I get what I want: -...
2 votes
2 answers
512 views

Stat function not working when passing file names of different directories [duplicate]

I am trying to implement the ls command and am getting stuck in the -i option using the stat() function to list inode numbers. The format is ./myls [options] [list of files] If I run ./myls -i . I ...
-1 votes
3 answers
5k views

What's the cmd line equivalent of "ls -a" in Powershell on Windows Vscode?

I want a to display ALL files (including hidden ones) on a directory in Powershell opened in Windows VsCode. I want the Powershell equivalent of 'ls -a'. How do I do that? I've tried: dir ./d dir /a ...
0 votes
1 answer
246 views

LSD (LSDeluxe) in Git Bash

I have tried using LSD and I have a small problem when I use it in CMD it looks very good. LSD in CMD But when I type LSD in Git Bash the colors are not there but just some text LSD in Git Does ...
0 votes
4 answers
136 views

powershell ls errors certain folders / files

I'm looking at doing a recursive Get-ChildItem -r to get lastWriteTime, length and group for count by extension. I get a bunch of errors, e.g., 'Get-ChildItem : Could not find item C:\Pics & ...
0 votes
1 answer
91 views

bash removing slashes in front of directory names

I'm trying to recapture some of the simplicity of the c-shell and tcsh. I had a simple alias that allowed me to list directories (alias lsdd 'ls | grep /'). I found a post with several solutions, none ...
0 votes
0 answers
33 views

Error in ls command in linux (ls: reading directory “.”: Operation not permitted) and unable to access jar file

I am trying to extract orc files from the database using ubuntu2_ssh, linux platform. The orc files are inside this folder called “100622” but I encountered error when “ls” command is typed. Error ...
  • 39
0 votes
1 answer
590 views

Cding into directory hangs terminal

I am encountering a really weird issue when trying to "cd" into a specific directory (e.g. directory_A) along a path. Whenever I try to "cd", my linux terminal immediately hangs ...
0 votes
0 answers
308 views

how to print path of a file pointed by a symbolic link in C like tree or ls -l does

here's my problem: Im writing a simplified tree command with C language. When I find a file that's a symbolic link i would print something like: SymbolicFile -> ../.././something.. So i've tried to ...
0 votes
2 answers
93 views

printing output of ls | wc -l in a txt file with two columns

I have many directories with different number of CSV files in each of them. I am interested in getting a list of those directories with a their respective number of CSV files. So I have this bash loop....
  • 95
1 vote
0 answers
89 views

VM to VM: Socket Connect() returning -1

So, I am working on an remote ls assignment in which we have to use TCP socket connection between two remote computers and run client.c on one side and server.c on another. Client program enters ...
  • 107

1
2 3 4 5
27