Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Add Comment
Please, Sign In to add comment