You are not logged in.

#1 2024-06-10 15:44:12

loutch
Member
Registered: 2015-12-12
Posts: 848

jq raw --output

Hello

I'm trying this

jq --raw-output '.current | .[]' $HOME/Accuweather/raws > $HOME/Accuweather/conditions

i have any condition file but it is empty .

any idea .


Tanks

@+


Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX

Offline

#2 2024-06-10 16:03:18

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: jq raw --output

https://www.baeldung.com/linux/checking … mmand-line

But why not just...

curl wttr.in

Or output to a text file ...

curl wttr.in > currentWeather.txt

... though I don't know how to do that without there being a lot of missing characters in the text file.

Thanks for posting, that terminal output tha I found is crazy good on my system (colors, arrows, blinking lightning bolts!)


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#3 2024-06-10 16:55:21

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,737

Re: jq raw --output

@loutch, Can you provide an example input json and an idea on what you want as output?

Offline

#4 2024-06-10 16:57:23

loutch
Member
Registered: 2015-12-12
Posts: 848

Re: jq raw --output

current file


[
  {
    "LocalObservationDateTime": "2024-06-10T18:26:00+02:00",
    "EpochTime": 1718036760,
    "WeatherText": "Nuageux",
    "WeatherIcon": 7,
    "HasPrecipitation": false,
    "PrecipitationType": null,
    "IsDayTime": true,
    "Temperature": {
      "Metric": {
        "Value": 15,
        "Unit": "C",
        "UnitType": 17
      },
      "Imperial": {
        "Value": 59,
        "Unit": "F",
        "UnitType": 18
      }
    },
    "RealFeelTemperature": {
      "Metric": {
        "Value": 11.9,
        "Unit": "C",
        "UnitType": 17,
        "Phrase": "Frais"
      },
      "Imperial": {
        "Value": 54,
        "Unit": "F",
        "UnitType": 18,
        "Phrase": "Frais"
      }
    },
    "RealFeelTemperatureShade": {
      "Metric": {
        "Value": 11.9,
        "Unit": "C",
        "UnitType": 17,
        "Phrase": "Frais"
      },
      "Imperial": {
        "Value": 54,
        "Unit": "F",
        "UnitType": 18,
        "Phrase": "Frais"
      }
    },
    "RelativeHumidity": 62,
    "IndoorRelativeHumidity": 45,
    "DewPoint": {
      "Metric": {
        "Value": 7.8,
        "Unit": "C",
        "UnitType": 17
      },
      "Imperial": {
        "Value": 46,
        "Unit": "F",
        "UnitType": 18
      }
    },
    "Wind": {
      "Direction": {
        "Degrees": 270,
        "Localized": "O",
        "English": "W"
      },
      "Speed": {
        "Metric": {
          "Value": 24.1,
          "Unit": "km/h",
          "UnitType": 7
        },
        "Imperial": {
          "Value": 15,
          "Unit": "mi/h",
          "UnitType": 9
        }
      }
    },
    "WindGust": {
      "Speed": {
        "Metric": {
          "Value": 24.1,
          "Unit": "km/h",
          "UnitType": 7
        },
        "Imperial": {
          "Value": 15,
          "Unit": "mi/h",
          "UnitType": 9
        }
      }
    },
    "UVIndex": 0,
    "UVIndexText": "Minimum",
    "Visibility": {
      "Metric": {
        "Value": 16.1,
        "Unit": "km",
        "UnitType": 6
      },
      "Imperial": {
        "Value": 10,
        "Unit": "mi",
        "UnitType": 2
      }
    },
    "ObstructionsToVisibility": "",
    "CloudCover": 95,
    "Ceiling": {
      "Metric": {
        "Value": 1219,
        "Unit": "m",
        "UnitType": 5
      },
      "Imperial": {
        "Value": 4000,
        "Unit": "ft",
        "UnitType": 0
      }
    },
    "Pressure": {
      "Metric": {
        "Value": 1007.2,
        "Unit": "mb",
        "UnitType": 14
      },
      "Imperial": {
        "Value": 29.74,
        "Unit": "inHg",
        "UnitType": 12
      }
    },
    "PressureTendency": {
      "LocalizedText": "Stationnaire",
      "Code": "S"
    },
    "Past24HourTemperatureDeparture": {
      "Metric": {
        "Value": -6.1,
        "Unit": "C",
        "UnitType": 17
      },
      "Imperial": {
        "Value": -11,
        "Unit": "F",
        "UnitType": 18
      }
    },
    "ApparentTemperature": {
      "Metric": {
        "Value": 17.8,
        "Unit": "C",
        "UnitType": 17
      },
      "Imperial": {
        "Value": 64,
        "Unit": "F",
        "UnitType": 18
      }
    },
    "WindChillTemperature": {
      "Metric": {
        "Value": 15,
        "Unit": "C",
        "UnitType": 17
      },
      "Imperial": {
        "Value": 59,
        "Unit": "F",
        "UnitType": 18
      }
    },
    "WetBulbTemperature": {
      "Metric": {
        "Value": 11,
        "Unit": "C",
        "UnitType": 17
      },
      "Imperial": {
        "Value": 52,
        "Unit": "F",
        "UnitType": 18
      }
    },
    "WetBulbGlobeTemperature": {
      "Metric": {
        "Value": 12.7,
        "Unit": "C",
        "UnitType": 17
      },
      "Imperial": {
        "Value": 55,
        "Unit": "F",
        "UnitType": 18
      }
    },
    "Precip1hr": {
      "Metric": {
        "Value": 0,
        "Unit": "mm",
        "UnitType": 3
      },
      "Imperial": {
        "Value": 0,
        "Unit": "in",
        "UnitType": 1
      }
    },
    "PrecipitationSummary": {
      "Precipitation": {
        "Metric": {
          "Value": 0,
          "Unit": "mm",
          "UnitType": 3
        },
        "Imperial": {
          "Value": 0,
          "Unit": "in",
          "UnitType": 1
        }
      },
      "PastHour": {
        "Metric": {
          "Value": 0,
          "Unit": "mm",
          "UnitType": 3
        },
        "Imperial": {
          "Value": 0,
          "Unit": "in",
          "UnitType": 1
        }
      },
      "Past3Hours": {
        "Metric": {
          "Value": 0,
          "Unit": "mm",
          "UnitType": 3
        },
        "Imperial": {
          "Value": 0,
          "Unit": "in",
          "UnitType": 1
        }
      },
      "Past6Hours": {
        "Metric": {
          "Value": 0,
          "Unit": "mm",
          "UnitType": 3
        },
        "Imperial": {
          "Value": 0,
          "Unit": "in",
          "UnitType": 1
        }
      },
      "Past9Hours": {
        "Metric": {
          "Value": 0,
          "Unit": "mm",
          "UnitType": 3
        },
        "Imperial": {
          "Value": 0,
          "Unit": "in",
          "UnitType": 1
        }
      },
      "Past12Hours": {
        "Metric": {
          "Value": 0,
          "Unit": "mm",
          "UnitType": 3
        },
        "Imperial": {
          "Value": 0,
          "Unit": "in",
          "UnitType": 1
        }
      },
      "Past18Hours": {
        "Metric": {
          "Value": 0,
          "Unit": "mm",
          "UnitType": 3
        },
        "Imperial": {
          "Value": 0,
          "Unit": "in",
          "UnitType": 1
        }
      },
      "Past24Hours": {
        "Metric": {
          "Value": 0,
          "Unit": "mm",
          "UnitType": 3
        },
        "Imperial": {
          "Value": 0,
          "Unit": "in",
          "UnitType": 1
        }
      }
    },
    "TemperatureSummary": {
      "Past6HourRange": {
        "Minimum": {
          "Metric": {
            "Value": 15,
            "Unit": "C",
            "UnitType": 17
          },
          "Imperial": {
            "Value": 59,
            "Unit": "F",
            "UnitType": 18
          }
        },
        "Maximum": {
          "Metric": {
            "Value": 19.4,
            "Unit": "C",
            "UnitType": 17
          },
          "Imperial": {
            "Value": 67,
            "Unit": "F",
            "UnitType": 18
          }
        }
      },
      "Past12HourRange": {
        "Minimum": {
          "Metric": {
            "Value": 7.8,
            "Unit": "C",
            "UnitType": 17
          },
          "Imperial": {
            "Value": 46,
            "Unit": "F",
            "UnitType": 18
          }
        },
        "Maximum": {
          "Metric": {
            "Value": 19.4,
            "Unit": "C",
            "UnitType": 17
          },
          "Imperial": {
            "Value": 67,
            "Unit": "F",
            "UnitType": 18
          }
        }
      },
      "Past24HourRange": {
        "Minimum": {
          "Metric": {
            "Value": 7.8,
            "Unit": "C",
            "UnitType": 17
          },
          "Imperial": {
            "Value": 46,
            "Unit": "F",
            "UnitType": 18
          }
        },
        "Maximum": {
          "Metric": {
            "Value": 21.1,
            "Unit": "C",
            "UnitType": 17
          },
          "Imperial": {
            "Value": 70,
            "Unit": "F",
            "UnitType": 18
          }
        }
      }
    },
    "MobileLink": "http://www.accuweather.com/fr/fr/sarreguemines/135050/current-weather/135050",
    "Link": "http://www.accuweather.com/fr/fr/sarreguemines/135050/current-weather/135050"
  }
]

i would have a file like accuweather_conky_script

7
15
12
Cloudy
O
24 km/h
62%
↔ 1007 mb
0 Low
95%
62%
8
16 km
05:26 AM
09:36 PM
16:10
24 km/h
08:55 AM
01:08 AM
16:13
1200 m
e
05:26
21:36
08:55
01:08
5

Last edited by loutch (2024-06-10 16:59:08)


Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX

Offline

#5 2024-06-10 17:17:40

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,737

Re: jq raw --output

ok, with a little help from chatgpt, this:

cat loutch.json | jq --raw-output '
.[0] | "
Observation Time: \(.LocalObservationDateTime)
Weather: \(.WeatherText)
Temperature: \(.Temperature.Imperial.Value)°\(.Temperature.Imperial.Unit)
Real Feel Temperature: \(.RealFeelTemperature.Imperial.Value)°\(.RealFeelTemperature.Imperial.Unit) (\(.RealFeelTemperature.Imperial.Phrase))
Relative Humidity: \(.RelativeHumidity)%
Wind: \(.Wind.Speed.Imperial.Value) \(.Wind.Speed.Imperial.Unit) from \(.Wind.Direction.English) (\(.Wind.Direction.Degrees)°)
Visibility: \(.Visibility.Imperial.Value) \(.Visibility.Imperial.Unit)
Pressure: \(.Pressure.Imperial.Value) \(.Pressure.Imperial.Unit)
Cloud Cover: \(.CloudCover)%
Precipitation (Last 24 Hours): \(.PrecipitationSummary.Past24Hours.Imperial.Value) \(.PrecipitationSummary.Past24Hours.Imperial.Unit)
" '

returns this:

Observation Time: 2024-06-10T18:26:00+02:00
Weather: Nuageux
Temperature: 59°F
Real Feel Temperature: 54°F (Frais)
Relative Humidity: 62%
Wind: 15 mi/h from W (270°)
Visibility: 10 mi
Pressure: 29.74 inHg
Cloud Cover: 95%
Precipitation (Last 24 Hours): 0 in

Offline

#6 2024-06-11 00:56:41

marens
Member
From: World without M$
Registered: 2023-02-02
Posts: 827

Re: jq raw --output

@loutch

I don't have jq  installed but I'll try to help.
I guess you need it for the accuweather  conky.

Similar to @bronto, I created a loutch.json  file with your content in the HOME directory.

This is my solution:

$ sed '1,2d' $HOME/loutch.json | sed 's/{//g' | sed 's/}//g' | sed 's/},//g' | sed 's/"//g' | sed 's/,//g' | sed 's/^.\{4\}//g' | sed 's/\]//g' | sed 's/MobileLink: http:\/\/www.accuweather.com\/fr\/fr\/sarreguemines\/135050\/current-weather\/135050//g' | sed 's/Link: http:\/\/www.accuweather.com\/fr\/fr\/sarreguemines\/135050\/current-weather\/135050//g' | sed -e '/^$/d' > $HOME/conditions

You will get the conditions file in the HOME folder:

LocalObservationDateTime: 2024-06-10T18:26:00+02:00
EpochTime: 1718036760
WeatherText: Nuageux
WeatherIcon: 7
HasPrecipitation: false
PrecipitationType: null
IsDayTime: true
Temperature: 
  Metric: 
    Value: 15
    Unit: C
    UnitType: 17
  
  Imperial: 
    Value: 59
    Unit: F
    UnitType: 18
  
RealFeelTemperature: 
  Metric: 
    Value: 11.9
    Unit: C
    UnitType: 17
    Phrase: Frais
  
  Imperial: 
    Value: 54
    Unit: F
    UnitType: 18
    Phrase: Frais
  
RealFeelTemperatureShade: 
  Metric: 
    Value: 11.9
    Unit: C
    UnitType: 17
    Phrase: Frais
  
  Imperial: 
    Value: 54
    Unit: F
    UnitType: 18
    Phrase: Frais
  
RelativeHumidity: 62
IndoorRelativeHumidity: 45
DewPoint: 
  Metric: 
    Value: 7.8
    Unit: C
    UnitType: 17
  
  Imperial: 
    Value: 46
    Unit: F
    UnitType: 18
  
Wind: 
  Direction: 
    Degrees: 270
    Localized: O
    English: W
  
  Speed: 
    Metric: 
      Value: 24.1
      Unit: km/h
      UnitType: 7
    
    Imperial: 
      Value: 15
      Unit: mi/h
      UnitType: 9
    
  
WindGust: 
  Speed: 
    Metric: 
      Value: 24.1
      Unit: km/h
      UnitType: 7
    
    Imperial: 
      Value: 15
      Unit: mi/h
      UnitType: 9
    
  
UVIndex: 0
UVIndexText: Minimum
Visibility: 
  Metric: 
    Value: 16.1
    Unit: km
    UnitType: 6
  
  Imperial: 
    Value: 10
    Unit: mi
    UnitType: 2
  
ObstructionsToVisibility: 
CloudCover: 95
Ceiling: 
  Metric: 
    Value: 1219
    Unit: m
    UnitType: 5
  
  Imperial: 
    Value: 4000
    Unit: ft
    UnitType: 0
  
Pressure: 
  Metric: 
    Value: 1007.2
    Unit: mb
    UnitType: 14
  
  Imperial: 
    Value: 29.74
    Unit: inHg
    UnitType: 12
  
PressureTendency: 
  LocalizedText: Stationnaire
  Code: S
Past24HourTemperatureDeparture: 
  Metric: 
    Value: -6.1
    Unit: C
    UnitType: 17
  
  Imperial: 
    Value: -11
    Unit: F
    UnitType: 18
  
ApparentTemperature: 
  Metric: 
    Value: 17.8
    Unit: C
    UnitType: 17
  
  Imperial: 
    Value: 64
    Unit: F
    UnitType: 18
  
WindChillTemperature: 
  Metric: 
    Value: 15
    Unit: C
    UnitType: 17
  
  Imperial: 
    Value: 59
    Unit: F
    UnitType: 18
  
WetBulbTemperature: 
  Metric: 
    Value: 11
    Unit: C
    UnitType: 17
  
  Imperial: 
    Value: 52
    Unit: F
    UnitType: 18
  
WetBulbGlobeTemperature: 
  Metric: 
    Value: 12.7
    Unit: C
    UnitType: 17
  
  Imperial: 
    Value: 55
    Unit: F
    UnitType: 18
  
Precip1hr: 
  Metric: 
    Value: 0
    Unit: mm
    UnitType: 3
  
  Imperial: 
    Value: 0
    Unit: in
    UnitType: 1
  
PrecipitationSummary: 
  Precipitation: 
    Metric: 
      Value: 0
      Unit: mm
      UnitType: 3
    
    Imperial: 
      Value: 0
      Unit: in
      UnitType: 1
    
  
  PastHour: 
    Metric: 
      Value: 0
      Unit: mm
      UnitType: 3
    
    Imperial: 
      Value: 0
      Unit: in
      UnitType: 1
    
  
  Past3Hours: 
    Metric: 
      Value: 0
      Unit: mm
      UnitType: 3
    
    Imperial: 
      Value: 0
      Unit: in
      UnitType: 1
    
  
  Past6Hours: 
    Metric: 
      Value: 0
      Unit: mm
      UnitType: 3
    
    Imperial: 
      Value: 0
      Unit: in
      UnitType: 1
    
  
  Past9Hours: 
    Metric: 
      Value: 0
      Unit: mm
      UnitType: 3
    
    Imperial: 
      Value: 0
      Unit: in
      UnitType: 1
    
  
  Past12Hours: 
    Metric: 
      Value: 0
      Unit: mm
      UnitType: 3
    
    Imperial: 
      Value: 0
      Unit: in
      UnitType: 1
    
  
  Past18Hours: 
    Metric: 
      Value: 0
      Unit: mm
      UnitType: 3
    
    Imperial: 
      Value: 0
      Unit: in
      UnitType: 1
    
  
  Past24Hours: 
    Metric: 
      Value: 0
      Unit: mm
      UnitType: 3
    
    Imperial: 
      Value: 0
      Unit: in
      UnitType: 1
    
  
TemperatureSummary: 
  Past6HourRange: 
    Minimum: 
      Metric: 
        Value: 15
        Unit: C
        UnitType: 17
      
      Imperial: 
        Value: 59
        Unit: F
        UnitType: 18
      
    
    Maximum: 
      Metric: 
        Value: 19.4
        Unit: C
        UnitType: 17
      
      Imperial: 
        Value: 67
        Unit: F
        UnitType: 18
      
    
  
  Past12HourRange: 
    Minimum: 
      Metric: 
        Value: 7.8
        Unit: C
        UnitType: 17
      
      Imperial: 
        Value: 46
        Unit: F
        UnitType: 18
      
    
    Maximum: 
      Metric: 
        Value: 19.4
        Unit: C
        UnitType: 17
      
      Imperial: 
        Value: 67
        Unit: F
        UnitType: 18
      
    
  
  Past24HourRange: 
    Minimum: 
      Metric: 
        Value: 7.8
        Unit: C
        UnitType: 17
      
      Imperial: 
        Value: 46
        Unit: F
        UnitType: 18
      
    
    Maximum: 
      Metric: 
        Value: 21.1
        Unit: C
        UnitType: 17
      
      Imperial: 
        Value: 70
        Unit: F
        UnitType: 18

       

It is very easy to use.

If you need temperature (metric value):

$ sed -n '10p' $HOME/conditions | awk '{print $2}'
15

If people would know how little brain is ruling the world, they would die of fear.

Offline

#7 2024-06-11 17:50:25

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: jq raw --output

AWESOME Link.

One OOPSIE! with metar man page.  It points to a NOAA site that is not available anymore:

metar requires at least one station identifier to run. A full list of ICAO stations is available for download at
http://weather.noaa.gov/data/nsd_bbsss.txt.

You can get a list: wp10_atta.pdf at: icao.international

or of course Wikipedia: ICAO airport code

A no frills CLI output for Buenos Aires from wttr.in

 2024·06·11 @ 14:46:22 ~
   $ caba
 Buenos Aires, Argentina
 Overcast
 T: +14°C ST: +13°C Hum: 82%
 Wind: ←17km/h BAR: 1016hPa Rain: 0.0mm
 Dawn: 07:29:17 SunRise: 07:57:45
 Zenith: 12:53:25
 Sunset: 17:49:17 Dusk: 18:17:45
 
 2024·06·11 @ 14:46:27 ~
   $ 

The bash alias code:

alias caba='curl wttr.in/Buenos+Aires?format="+Buenos+Aires,+Argentina\n+%C\n+T:+%t+ST:+%f+Hum:+%h\n+Wind:+%w+BAR:+%P+Rain:+%p\n+Dawn:+%D+SunRise:+%S\n+Zenith:+%z\n+Sunset:+%s+Dusk:+%d\n"'

We now return you to loutch and his problem.

ST = Feels Like


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#8 2024-06-13 06:58:37

loutch
Member
Registered: 2015-12-12
Posts: 848

Re: jq raw --output

Hello

Guys , it work great


TANKS

@+


Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX

Offline

Board footer

Powered by FluxBB