Tag Info

New answers tagged

0

For posterity, the powershell script I have used is: Get-Childitem C:\MyDirectory -Recurse | WHERE { -NOT $_.PSIsContainer } | Group Extension -NoElement | Sort Count -Desc > FileExtensions.txt Also, you could potentially run it from the command line/batch file: Powershell -Command "& Get-Childitem C:\MyDirectory -Recurse | WHERE { -NOT ...


3

Use conditional parameter expansion: List="A B C D" for I in $List do OUT="${OUT:+$OUT }-$I" done The expression ${OUT:+$OUT } expands to nothing if OUT is not set or empty; if it is set to something, then it expands to that something followed by a space. However, this sort of operation - treating a whitespace-separated string as a list - is fraught ...


0

You can remove the leading space using a command after the for-loop, such as OUT=${OUT# } Leading to List="A B C D" for I in $List do OUT=$OUT" -$I" done OUT=${OUT# }


0

ash is a very stripped down shell. It probably does not support the syntax function myFuncname { ...; } Use this instead myFuncname() { ...; }


0

If it's the first available preferred network (Network Preferences, Advanced, "Remember networks this computer has joined" is checked) and you don't have "Require administrator authorization to: - Turn Wi-Fi on or off" checked you can use networksetup -setairportpower en0 off followed by by networksetup -setairportpower en0 on and it will connect to the ...


0

Here are couple of ways to do it. myvar="This is a test" echo "${#myvar}" 14 Or expr length "$myvar" 14


1

I don't think "pure sh" can do it. But you don't need to do anything in "pure sh"; you need to do it in sh plus standard utilities. The most straightforward way is: strlength=`expr "$string" : ".*"` (expr is POSIX). Or if you don't have expr (Solaris 5.1 is ancient), you could also use wc together with printf like: strlength=`printf "%s" "$string" | wc ...


0

wc -m counts the chars in a string. So you can do something like: STRLENGTH=$(echo -n $STRING | wc -m) Alternative syntax: STRLENGTH=`echo -n $STRING | wc -m` The -n flag for echo stops it from printing a newline. The flag might be different on Solaris 5. Check man echo


0

ed -s FILE1 <<EOF /### BEGIN GENERATED/+,/### END GENERATED/-d /### BEGIN GENERATED/ r FILE2 w q EOF


0

have you tried set key_status to (do shell script " defaults read & path_to_plist & \" PlistKey\" ") ?


1

I could imagine that the output logging feature of screen could help You accomplish this (see the man page for details). You could produce output logs of Your sessions and check them to see if Your jobs have finished. Or You could check the tree of running processes (e.g. using pstree) to see if the shells within the screen sessions still have running ...


0

You can use AutoHotkey for that kind of tasks. AutoHotkey has very strong capability for hotkey management. Always use AutoHotkey and its documenatation from http://ahkscript.org/ (current uptodate version, new official website)! AutoHotkey and its documentation from autohotkey.com is outdated and you may have some problems using them!


0

I feel absolutely silly. The -L option was all I needed. From the man page: -L, --location (HTTP/HTTPS) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with ...


0

This populates an array and prints it You could use names1 names2 names3, rather than names[1] names[2] names[3] by writing names!i! instead of names[!i!]. It produces the array by generating variable names. There isn't an array structure in batch. But it is as neat as any array structure, and populating or printing looks exactly like how one would ...


0

A good way to do it is using gzip to compress files. If you need to package multiple files up into one big one, try looking into tar, then gzip them after you do that. It sounds like an assignment so that should put you in the right direction.


0

Something like this in a batch file? Select a file in a folder. << is comment, no code :selectapk SETLOCAL ENABLEDELAYEDEXPANSION << DELAYED EXPANSION on for counter in For loop SET /A MAXITEM=0 Echo. Echo Found these APK files in "add_apk_here" folder. Echo. For %%a in (add_apk_here/*.apk) do ( Set /A MAXITEM+=1 Set MENUITEM!MAXITEM!=%%a ...


1

arrays of arrays are really quite painful in bash host=ny113 for grp in "${SERVERGROUP[@]}"; do ref="${grp}[@]" for srv in "${!ref}"; do if [[ $host == $srv ]]; then echo $host is in $grp break 2 fi done done ny113 is in NY Using associative arrays (bash version 4) is another approach: declare -A ...


0

If your using Bash, there is the command called date. #!/bin/bash date > /path/to/your/logfile; node your_program && date >> /path/to/your/logfile naturally you will have to add your node program and whatever arguments after node in the script, and you will have to designate the your logfile, but that should output the time (granted ...


4

I've solved the problem with the bash ${var:+...} extension, (reference). The script now changes to curl \ ${title:+ --data-urlencode "title=${title}"} \ http://example.com which works perfectly. Also see: Bash - function with optional arguments and missing logic How to write a bash script that takes optional input arguments?


0

Install lastpass extension, add site/account, choose auto-login when adding the site. Start chome from command line google-chorme <URL> It should log you in.


1

Haven't tried it for your specific use, but I would suggest giving keybroadcast a shot.


1

You can give -c option to vim to execute commands after the first file has been read, like this: (modified line from your script) my $e = "-e 'vim -c \"source /path/to/my/file\" " . $file . "'"; Read about it: :help -c


0

This is what IETF ZeroConf networking is for. Android supports it (they call it Network Service Discovery or NSD), and iOS and OS X support the hell out of it, because it's what Apple calls Bonjour. Apple has a Bonjour for Windows that you can install on Windows, and Linux platforms have various options such as Avahi. If you've got the dns-sd command-line ...


0

In the past I have had /M problems in python scripts written on a windows box and trying to use them on a linux box. I used dos2unix to convert the files to make them operable on the linux box. If carriage returns (or other windows text formatting issues) exist and are the cause of the problem this might help.


0

binfmt_misc is not loaded on that VM where it is on the others. On debian, install it via the binfmt-support package.



Top 50 recent answers are included