Last active
July 18, 2018 06:27
-
-
Save flannon/103a6dc6bb31721ec8dccbe44e1caf1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jq notes | |
Show names and ids of all efs file systems | |
$ aws efs describe-file-systems | jq '.FileSystems[] | {FileSystems: .Name, FileSystemId}' | |
Select a single file system based on its name tag, | |
$ aws efs describe-file-systems | jq '.FileSystems[] | select(.Name == "my_fs_name")' | |
Using two select statements for two fields returns two identical records (?) | |
aws efs describe-file-systems | jq '.FileSystems[] | select(.Name | contains("my_fs_name")), select(.FileSystemId | contains("fs-00000000"))' | |
Return the fs record only if both fields match, | |
$ aws efs describe-file-systems | jq '.FileSystems[] | select(.Name == "my_fs_name") | select(.FileSystemId | contains("fs-00000000"))?' | |
Doing it with grep and awk | |
- $aws efs describe-file-systems | jq '.FileSystems[] | select(.Name == "my_fs_name")' | grep FileSystemId | awk -F':' '{print $2}' | awk -F"\"" '{print $2}' | |
Only return a value if both the file system name and the file system id match the given values, | |
- $ aws efs describe-file-systems | jq '.FileSystems[] | select(.Name == "my_fs_name")' | jq '. | select(.FileSystemId == "fs-000000000")' | |
Show just the filesystem if, | |
- $ FSID=$( aws efs describe-file-systems | jq '.FileSystems[] | select(.Name == "my_ef_name")' | jq '. | .FileSystemId') | |
- $ echo ${FSID:1:11} | |
Or just do it with sed, | |
- $ FSID=$(aws efs describe-file-systems | jq '.FileSystems[] | select(.Name == "my_ef_name")' | jq '. | .FileSystemId' | sed -e s/\"//g) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment