find

Powershell to find Server Operating system

时光毁灭记忆、已成空白 提交于 2020-01-11 09:49:29
问题 I had a task to find Operating System of all the servers we had in AD for some Microsoft Licenses requirement. Has anyone done this? 回答1: I figured it out. Please feel free to use it and modify it. If you have questions, let me know. It's a simple command. Hopefully, it helps someone. This gives you the type of operating systems you have. I am filtering based on Windows Server only and computer accounts that are active. Then sort by name and select unique OS. Get-ADComputer -Filter {

Save output from FIND command to variable

一世执手 提交于 2020-01-11 07:00:50
问题 Like the title says, I'm trying to take the output from a FIND command and save it to a variable. Specifically, I'm using: DIR /b /s "C:\" | FIND "someexe.exe" to locate a specific .exe file, which seems to work fine, but then I want to save the results of FIND to use later in the same script. I've tried various different tweaks of: for /f "usebackq" %%i in (`DIR /b /s "C:\" | FIND "someexe.exe"`) do SET foobar=%%i but when I try to run the script the command window immediately closes

find the latest modified file and exec

偶尔善良 提交于 2020-01-10 05:45:54
问题 I want to find out the latest built rpm in a directory and then exec something on it. Something similar to below. /bin/ls -1t srcdir/*.rpm | head -1 But with the find command find srcdir/*.rpm <get-only-the-most-recently-modified-file> -exec "<do-something>" 回答1: Two approaches -- one portable to non-GNU platforms, the other fast with large directories (to the extent allowed by the filesystem): Portable What? BashFAQ #3: How can I sort or compare files based on some metadata attribute (newest

How to use the name of the file with sed in a find expression

时光毁灭记忆、已成空白 提交于 2020-01-10 05:25:07
问题 Trying to answer Using Bash/Perl to modify files based on each file's name I ended in a point in which I don't know how to use find and sed all together. Let's say there is a certain structure of files in which we want to change a line, appending the name of the file. If it was a normal for loop we would do: for file in dir/* do sed -i "s/text/text plus $file/g" $file done But let's say we want to use find to change files from all subdirectories. In this case, I would use... find . -type f

VBA in find function runtime error 91

喜你入骨 提交于 2020-01-10 04:45:27
问题 My question is concerning the runtime error 91 in VBA for excel. I've done some searching to no avail. My code is below. I have noted the section causing the error. Why is this happening, and how can i fix it and move on? Sub RemoveFooterRows(theFile) Dim found As Range Dim aggregateRow ''Error is from section below found = isItRow = Workbooks(theFile).Worksheets(1).Columns(1).Find _ ("Summary", Range("A1"), xlValues, xlPart, xlByRows, xlNext, False, , False) ''Error is from section above

How to use pipe within -exec in find

独自空忆成欢 提交于 2020-01-09 10:14:53
问题 Is there any way to use pipe within an -exec in find? I don't want grep to go through whole file, but only through first line of each file. find /path/to/dir -type f -print -exec grep yourstring {} \; I tried to put the pipelines there with "cat" and "head -1", but it didn't work very well. I tried to use parenthesis somehow, but I didn't manage to work out how exactly to put them there. I would be very thankful for your help. I know how to work it out other way, without using the find, but

find type -f also returns non-matching files in matching directory

纵饮孤独 提交于 2020-01-07 04:22:08
问题 all files/folders in current directory: ./color_a.txt ./color_b.txt ./color_c.txt ./color/color_d.txt ./color/blue.txt ./color/red.txt ./color/yellow.txt command used to find all files with the word color in name: find ./*color* -type f result: ./color_a.txt ./color_b.txt ./color_c.txt ./color/color_d.txt ./color/blue.txt ./color/red.txt ./color/yellow.txt expected result: ./color_a.txt ./color_b.txt ./color_c.txt ./color/color_d.txt The result also includes all the non-matching file names

Check that any directory exists inside given one

廉价感情. 提交于 2020-01-07 02:19:05
问题 My application is Windows, C# 3.0. I want to make sure that a directory given does not contains subdirectories. Naive code like if (Directory.GetDirectories(path).Length != 0) will work very slow on directories which contain e.g. 10000 subdirectories, because it will build a list of subdirectories, while even 1 directory is already enough for me. Is there a way in .NET to determine 1 subdirectory quickly? 回答1: if (Directory.EnumerateDirectories().Any()) EnumerateDirectories will return

Find all duplicates and missing values in a sorted array

一个人想着一个人 提交于 2020-01-06 22:46:10
问题 Suppose you have a sorted range (x to y) of values in an array. x = 3; y = 11; array == 3, 4, 5, 6, 7, 8, 9, 10, 11 But it is possible that some values are duplicated and some are missing, so you might have: array == 4, 5, 5, 5, 7, 8, 9, 10, 10 What's the best way in your language to find all duplicates and missing values so you get: resultMissingValuesArray == 3, 6, 11 resultDuplicatesArray == 5, 5, 10 Here's some C++ code to get you started: #include <vector> #include <iostream> #include

Hexadecimal find and replace

冷暖自知 提交于 2020-01-06 19:44:22
问题 How to change a binary file hexadecimal character in a binary file? #include <stdio.h> #include <stdint.h> #include <string.h> #define BUFFER_SIZE 4096 int main(void) { uint8_t *buffer; // Explicit 8 bit unsigned, but should equal "unsigned char" FILE *file; char filename[512] = "test.bin"; // We could also have used buffer[BUFFER_SIZE], but this shows memory alloc if (NULL == (buffer = malloc(BUFFER_SIZE))) { fprintf(stderr, "out of memory\n"); return -1; } // Being inside a { }, crlf won't