Check These Out
Here's an annotated version of the command, using full-names instead of aliases. It is exactly equivalent to the short-hand version.
# Recursively list all the files in the current directory.
Get-ChildItem -Recurse |
# Filter out the sub-directories themselves.
Where-Object { return -not $_.PsIsContainer; } |
# Group the resulting files by their extensions.
Group-Object Extension |
# Pluck the Name and Count properties of each group and define
# a custom expression that calculates the average of the sizes
# of the files in that group.
# The back-tick is a line-continuation character.
Select-Object `
Name,
Count,
@{
Name = 'Average';
Expression = {
# Average the Length (sizes) of the files in the current group.
return ($_.Group | Measure-Object -Average Length).Average;
}
} |
# Format the results in a tabular view, automatically adjusted to
# widths of the values in the columns.
Format-Table -AutoSize `
@{
# Rename the Name property to something more sensible.
Name = 'Extension';
Expression = { return $_.Name; }
},
Count,
@{
# Format the Average property to display KB instead of bytes
# and use a formatting string to show it rounded to two decimals.
Name = 'Average Size (KB)';
# The "1KB" is a built-in constant which is equal to 1024.
Expression = { return $_.Average / 1KB };
FormatString = '{0:N2}'
}
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token.
This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use:
`awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'`
You must adapt the command line to include:
* $MFA_IDis ARN of the virtual MFA or serial number of the physical one
* TTL for the credentials
This is assuming that you're editing some file that has not been wrapped at 80 columns, and you want it to be wrapped. While in Vim, enter ex mode, and set the textwidth to 80 columns:
$ :set textwidth=80
Then, press:
$ gg
to get to the top of the file, and:
$ gqG
to wrap every line from the top to the bottom of the file at 80 characters.
Of course, this will lose any indentation blocks you've setup if typing up some source code, or doing type setting. You can make modifications to this command as needed, as 'gq' is the formatting command you want, then you could send the formatting to a specific line in the file, rather than to the end of the file.
$ gq49G
Will apply the format from your current cursor location to the 49th row. And so on.
Replace PACKAGE with desired package name.
Found here: http://mikebeach.org/2011/04/undo-apt-get-build-dep/
Here's an awk version.