ls

Find missing numbers in continuous filenames (advanced ls & find)

落花浮王杯 提交于 2019-12-12 04:43:59
问题 Let's say I have a script that generates incrementing folder names over time (100, 101, 102, 103, 104, etc...). These folders are synced between machines and there is a chance of creation failure for any given folder on system 2. System 1 is always in sync: 100/ 101/ 102/ 103/ 104/ etc... System 2 may have errors: 100/ 102/ 103/ etc... (as you can see, 101/ & 104/ are missing on system 2) How can I generate a list of all the missing folders on System 2? P.S. Rsync is not really an option

List file using ls with a condition and process/grep files that only whitespaces

二次信任 提交于 2019-12-12 03:29:35
问题 I have a list of files in a folder which some of the files have spaces in the filename. I need to replace the whitespace with _ but first, i need to list the file with condition ls *_[1-4]*[A-c]* . After filter the files, some of the files have whitespace with no fixed position(front, middle, end position). How can i replace the whitespace after ls command? 回答1: You don't want to process the output from ls. Simply loop over the matching files. for file in *_[1-4]*[A-c]*; do # Skip files which

Searching images with Googliser.sh in Mac: “ls: illegal option — I”

感情迁移 提交于 2019-12-12 03:29:05
问题 I have a question over the script Googliser and the Mac commands. I tried the script some days ago in the Mac shell and made it work. I followed the script listed here: brew install wget brew install gnu-getopt brew link --force gnu-getopt curl -sO https://raw.githubusercontent.com/teracow/googliser/master/googliser.sh sed -i "" "s/readlink/stat/;s/dev\/shm/tmp/;s/p -p/p -t/" googliser.sh chmod +x googliser.sh Easy. It worked, not the first time, and I don't remember how I made it work. But

How do I redirect cmd ftp ls command output to a C# variable

徘徊边缘 提交于 2019-12-12 01:38:48
问题 I have been trying to figure this for hours, and can't seem to find a straight answer. I have found similar questions but none seem to work with what I am trying to do here. I am trying to avoid having to write to a file. If I can redirect to a variable, that would be great. Given the following code: static void Main(string[] args) { const int VK_RETURN = 0x0D; const int WM_KEYDOWN = 0x100; var cmd = new Process(); cmd.StartInfo.FileName = "cmd.exe"; cmd.StartInfo.UseShellExecute = false; cmd

GNU 'ls' command not outputing the same over a pipe [duplicate]

瘦欲@ 提交于 2019-12-11 11:39:23
问题 This question already has answers here : Why does ls give different output when piped (3 answers) Closed 3 years ago . When I execute the command ls on my system, I get the following output: System:~ user# ls asd goodfile testfile this is a test file However, when I pipe ls to another program (such as cat or gawk ), the following is output: System:~ user# ls | cat asd goodfile testfile this is a test file How do I get ls to read the terminal size and output the same over a pipe as it does

How to display only hidden files in directory using ls command in Bash

风格不统一 提交于 2019-12-11 06:04:02
问题 I am trying to display the hidden files from a directory using the ls command alone, except for . and .. . ls -lAd .* But the command returns . and .. directory names also in the output . What's wrong in this command even though I mentioned "A" option with ls . 回答1: You could use GLOBIGNORE internal variable. $ GLOBIGNORE=.:.. $ ls -ld .* 回答2: This is here for reference but the answer is given by @anishsane below. Your glob is wrong: .* will be expanded to . , and .. . You can either change

rm(list = ls()) doesn't work inside a function. Why? [duplicate]

和自甴很熟 提交于 2019-12-11 05:09:00
问题 This question already has an answer here : Why does rm inside a function not delete objects? (1 answer) Closed 2 years ago . I'm trying to create a function that will, simultaneously, clear the workspace and the memory so that, rather than having to type "rm(list = ls()); gc()", I can type just one function. But rm(list = ls()) doesn't work when it's called from within a function. Why? Is there any way around this? > # Let's create an object > x = 0 > ls() [1] "x" > > # This works fine: > rm

How to check if a file is executable in Bash [duplicate]

血红的双手。 提交于 2019-12-11 02:05:38
问题 This question already has answers here : Check if a file is executable (4 answers) Closed 4 days ago . I am trying to build a condition that check if file has execute access bit set. I can't use grep and find. I tried something with checking the "x" letter in the ls -l command but this is wrong in many cases. for val in `ls $1` do if [[ "`ls -l $1/$val`" -eq *w* ]] then rm $1/$val fi done Please help or give some advices! 回答1: There is no need to parse the output of ls to see if a file is

scp files in a certain order using ls

独自空忆成欢 提交于 2019-12-10 17:31:03
问题 Whenever I try to SCP files (in bash), they end up in a seemingly random(?) order. I've found a simple but not-very-elegant way of keeping a desired order, described below. Is there a clever way of doing it? Edit: deleted my early solution from here, cleaned, adapted using other suggestions, and added as an answer below. 回答1: To send files from a local machine (e.g. your laptop) to a remote (e.g. your calculation server), you can use Merlin2011's clever solution: Go into the folder in your

Error during subprocess calling ls

﹥>﹥吖頭↗ 提交于 2019-12-10 10:29:55
问题 any idea what is the error trying to say? Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> subprocess.call(["ls", "-l"]) File "D:\Python27\lib\subprocess.py", line 522, in call return Popen(*popenargs, **kwargs).wait() File "D:\Python27\lib\subprocess.py", line 710, in __init__ errread, errwrite) File "D:\Python27\lib\subprocess.py", line 958, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified 回答1: You are calling the ls