@@ -1205,8 +1205,8 @@ print(type(converted)) # Output: <class 'float'>
1205
1205
| ------------| --------------|
1206
1206
| Force integer conversion | ` [int]"3.9" ` (becomes ` 3 ` i.e. truncates decimal) |
1207
1207
| Convert object to XML | ` [xml]$xmlString ` |
1208
- | Convert object to JSON | `$object | ConvertTo-Json` |
1209
- | Convert JSON to object | `$json | ConvertFrom-Json` |
1208
+ | Convert object to JSON | ` $object \ | ConvertTo-Json ` |
1209
+ | Convert JSON to object | ` $json \ | ConvertFrom-Json ` |
1210
1210
1211
1211
---
1212
1212
@@ -1249,10 +1249,10 @@ Bash scripting does not have built-in type casting like some other languages, bu
1249
1249
| Description | Code Examples |
1250
1250
| ------------| --------------|
1251
1251
| Convert string to integer | ` num=$(( "42" )) ` → ` 42 ` |
1252
- | Convert string to float (using ` bc ` ) | `echo "3.14" | bc` → ` 3.14` |
1252
+ | Convert string to float (using ` bc ` ) | ` echo "3.14" \ | bc ` → ` 3.14 ` |
1253
1253
| Convert integer to string | ` str="$num" ` → ` "42" ` |
1254
1254
| Convert ASCII value to character | ` printf \\$(printf '%o' 65) ` → ` 'A' ` |
1255
- | Convert boolean-like values | `[[ -n "$var" ]] && echo "True" | | echo "False"` |
1255
+ | Convert boolean-like values | ` [[ -n "$var" ]] && echo "True" \|\ | echo "False" ` |
1256
1256
1257
1257
---
1258
1258
@@ -1263,7 +1263,7 @@ Bash scripting does not have built-in type casting like some other languages, bu
1263
1263
| Convert string to array | ` IFS="," read -ra arr <<< "apple,banana,grape" ` |
1264
1264
| Convert array to string | ` echo "${arr[*]}" ` → ` "apple banana grape" ` |
1265
1265
| Convert list to associative array | ` declare -A myDict; myDict[key]="value" ` |
1266
- | Convert array to JSON (using ` jq ` ) | `echo '{"name":"Alice","age":30}' | jq` |
1266
+ | Convert array to JSON (using ` jq ` ) | ` echo '{"name":"Alice","age":30}' \ | jq ` |
1267
1267
1268
1268
---
1269
1269
@@ -1272,8 +1272,8 @@ Bash scripting does not have built-in type casting like some other languages, bu
1272
1272
| Description | Code Examples |
1273
1273
| ------------| --------------|
1274
1274
| Force integer conversion | ` num=$(( "3.9" )) ` → ` 3 ` (truncates decimal) |
1275
- | Convert object to JSON (using ` jq ` ) | `echo '{"name":"Alice"}' | jq` |
1276
- | Convert JSON to object (using ` jq ` ) | `echo '{"name":"Alice"}' | jq -r '.name'` |
1275
+ | Convert object to JSON (using ` jq ` ) | ` echo '{"name":"Alice"}' \ | jq ` |
1276
+ | Convert JSON to object (using ` jq ` ) | ` echo '{"name":"Alice"}' \ | jq -r '.name' ` |
1277
1277
1278
1278
---
1279
1279
@@ -1562,7 +1562,7 @@ print(my_tuple) # Output: ('apple', 'banana', 'cherry')
1562
1562
| ** Remove One Item** (Delete element at index ` 2 ` ) | ` unset Names[2] ` |
1563
1563
| ** Duplicate** (Create a copy of the array) | ` Cities=("${Cities[@]}") ` |
1564
1564
| ** Concatenate** (Merge two arrays) | ` Items=("${Fruits[@]}" "${Vegetables[@]}") ` |
1565
- | ** Read from File** (Store lines of a file into an array) | ` logs=( ` cat "system.log"` ) ` |
1565
+ | ** Read from File** (Store lines of a file into an array) | ` logs=($( cat "system.log") ) ` |
1566
1566
1567
1567
### ** Iteration**
1568
1568
0 commit comments