Skip to content
Advertisement

Tag: ls

bash ls output to file when ls finds no results

i’m relative new to scripting in bash, and made the following script: At the end of the script, i don’t make a new MLSready file. When i execute the script, i expect to see the result of the latest ‘ls -l’ command in my logfile, however (because i didn’t create a new MLSready file?) the output is redirected to my

ls to list matches in specified directory

How do I list matched results in a specified directory? On my Ubuntu server if I list the contents of a directory it correctly lists it. My working directory is /var/crash. Let’s say I want to list all files that contain ‘tar’. In this example there should only be one match i.e. start.txt All’s good so far. However if I

Why ls -Q give output as “Z\1” if the file name is ‘Z1’?

Why “ls -Q” give output as “z\1” if the file name is ‘z1’? The output is coming with double slash in between ‘z’ and ‘1’. Answer The -Q-Switch (also –quote-names) will quote the names. How this quoting is done is defined by the –quoting-style-Switch. Snippet from the man page: –quoting-style=WORD use quoting style WORD for entry names: literal, locale, shell,

ls command ignore specific directory [bash]

Tree: ls : Ignore specific file: ls -I c.txt : Ignore specific directory: ls -I Tests : (does not work – Tests directory should not appear) Answer The “man page” for the ls command explains that the -I flag accepts a pattern. So you can use a wildcard in your command: See: man ls or the commands online man page

link count and ls command

I’m learning file link count. Only when link count reaches 0 can file’s contents be deleted. In my test the process opens a file in directory “/home/hel/myfile” and sleep 10(s). At the same time I delete it using “rm /home/hel/myfile”. Then I use command “ls” and display No such file. But in fact, the file still exists because the fd

‘tree’ and ‘ls’ change text color on Linux command line

I’ve been having a peculiar issue caused by the tree command on Linux. When I call tree, the the color of the command prompt changes, and is only returned to normal by the ls command. I’m curious if others have encountered the same issue, and if they have fixes or workarounds. I’m using the solarized color scheme (though I’m not

list file key-pair sorted by time

I need to sort a filename pair sorted by time. Every file starts with AUSZUG or UMSATZ (and some numbers after). But the problem is that I cannot sort it by just time because some files can be uploaded (created) not as pair. For example, default sort: You can see, UMSATZ pair for AUSZUG_5785745789.TXT.GPG are in last line I can

Cutting the column including size

I want to cut the column which include the size of files . I use ls -l to view info about files in current localization . I save info about file in txt file ls -l > info.txt , and now I want to cut the column including size . I do cat info.txt | cut -d” -f6 but i

How to get file creation date/time in Bash/Debian?

I’m using Bash on Debian GNU/Linux 6.0. Is it possible to get the file creation date/time? Not the modification date/time. ls -lh a.txt and stat -c %y a.txt both only give the modification time. Answer Unfortunately your quest won’t be possible in general, as there are only 3 distinct time values stored for each of your files as defined by

Advertisement