How can I perform "snap switch" for all snaps?

I am desiring all of my snaps to be tracking latest/edge, and I am desiring the knowledge of how to cause this to occur without the requirement of manual specification for subsequent application of the aforementioned to every snap that is installed.

Manual replacement is not feasible if many snaps are installed.

There’s no such command but you can use a simple one liner:

snap list | awk '/^Name/ {next} // {print $1}' | \
    xargs snap switch --channel=latest/edge
1 Like

If I replace snap switch --channel=latest/edge with snap refresh --channel=latest/edge, shall it refresh all of the installed snaps to that track?

Unfortunately, this command is not apparently functional because it must be run as sudo via either execution of sudo -i before execution of the command, or insertion of sudo before snap switch, and because when it is invoked by sudo, it only switches the track of the first entry of the output of snap list (in my case 0ad). The output of execution of the three modifications to your command that I have attempted usage of is:

  1. beedellrokejulianlockhart@System-Product-Name:~$ snap list | awk '/^Name/ {next} // {print $1}' | \ xargs snap switch --channel=latest/edge error: access denied (try with sudo)

  2. beedellrokejulianlockhart@System-Product-Name:~$ snap list | awk '/^Name/ {next} // {print $1}' | \ xargs sudo snap switch --channel=latest/edge "0ad" switched to the "latest/edge" channel

  3. sudo -i root@System-Product-Name:~# snap list | awk '/^Name/ {next} // {print $1}' | \ xargs snap switch --channel=latest/edge "0ad" switched to the "latest/edge" channel

try

snap list | cut -d' ' -f1 | while read package; do \
    sudo snap switch --channel=latest/edge $package; done
1 Like

Using bash or sh:

(My edit adds syntax highlighting.)