You are not logged in.

#1 2013-01-09 22:09:45

mcarni
Member
Registered: 2011-02-13
Posts: 8

[SOLVED] script to backup installed packages

Hi guys,

I know it should be easy, but I keep failing...


I can generate the list of installed packages with:

comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > pkglist.txt 

and I woudl like to integrate into my backup script.

I was testing it with a script with only two lines:

#! /bin/bash
comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > pkglist.txt 

but I get:

mkpklist: line 3: syntax error near unexpected token `('
mkpklist: line 3: `comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > pkglist.txt '"

I tried different options with brackets in different places, but me being useless with these things I have no idea of what I am doing...

could anyone point me in the right direction?

Thanks a lot

M

Last edited by mcarni (2013-01-09 22:26:34)

Offline

#2 2013-01-09 22:20:47

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,611
Website

Re: [SOLVED] script to backup installed packages

Works for me:

% cat tit
#!/bin/bash
comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > tit.txt

And

% ./tit
% head tit.txt 
abs
archey3
arch-install-scripts
asciidoc
autoconf
autojump
automake
bash
binutils
bison

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2013-01-09 22:26:13

mcarni
Member
Registered: 2011-02-13
Posts: 8

Re: [SOLVED] script to backup installed packages

sorry and thanks graysky

I used to run my script with:

$ sh mkpklist

and this gives the error.

If I run it with

$ ./mkpklist

it works...

sorry

M

Offline

#4 2013-01-10 01:53:43

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: [SOLVED] script to backup installed packages

@mcarni, you know that when you use "sh <script>" you are specifying sh as the shell the script will be run with.  In otherwords, you are overriding the shebang (#!/bin/bash) with /bin/sh.  On our systems, we actually don't have an actual /bin/sh, as it is a symlink to bash.  But when it is called via that symlink, it actually does its best to act like the old bourne shell.

Offline

#5 2013-01-10 06:30:07

mcarni
Member
Registered: 2011-02-13
Posts: 8

Re: [SOLVED] script to backup installed packages

@ WonderWoofy,
ops... I actually didn't know, I thought that launching a script with "sh" or by "./" was the same thing...
when Graysky replied I did some google search and together with your explanation it all makes sense...
Thanks a lot
M

Offline

#6 2013-01-10 08:02:34

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,699
Website

Re: [SOLVED] script to backup installed packages

If you ever want to reinstall old packages, you may find armh useful.

Offline

#7 2013-01-10 19:32:20

mcarni
Member
Registered: 2011-02-13
Posts: 8

Re: [SOLVED] script to backup installed packages

Thanks Xyne, I will look into armh...i didn't know
actually I didn't know that I didn't know so many things....

Thanks

M

Offline

Board footer

Powered by FluxBB