Skip to content

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 fil…

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 Al…

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 comm…

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 disp…

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…

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 …