[SOLVED] Parsing output of pacman -Qm to an bash array

Hey guys,
I'm currently writing a small bash script to check if there are any updates for my packages installed from the AUR. For this I need to get an array from the output of
pacman -Qm
. I've tried this
packages=(`pacman -Qm`)
, but this isn't that what I've intended for.
I want to have an array like this
packages=("packagename version", "packagename version" ...)
Does anybody know the way, how to solve this problem?
Best regards,
the_metalgamer
Last edited by the_metalgamer (2013-02-23 22:24:11)

Just to clarify this:
With the solution in post #2 the IFS variable will contain just an "n". So any package name containing an "n" will be cut into pieces.
$ echo ${packages[1]}
e emyli es3 1.2-1
The correct splitting is not caused by the IFS variable but by the read command which ALWAYS stops reading at a newline no matter what the IFS is set to. So there is no need to set the IFS variable to anything different and just use
packages=(); while read -r; do packages+=("$REPLY"); done < <(pacman -Qm)

Similar Messages

  • Error parsing output

    Hi There,
    New to the Java World and Im getting the following error when submitting this java program for compilation and output. Output is Via a html page
    // just import the BufferedReader and inputstream reader
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    class addtwonumbers
        public static void main(String[] args)
        // system.in reader (e.g. the input from the console)
        InputStreamReader ISR = new InputStreamReader(System.in);
        // buffer the console reader
        BufferedReader BR = new BufferedReader(ISR);
        // the default values for the two numbers
        int val1 = 0;
        int val2 = 0;
        try
            // output the question.
            System.out.print("Enter two Numbers:\n");
            // read in the console intput one line (BR.readLine) and then convert to a integer
            val1 = Integer.parseInt(BR.readLine());
            val2 = Integer.parseInt(BR.readLine());
        catch (Exception ex)
            //if the input was a string.
            System.out.println(ex.toString());
        // output the answer of adding both of the values together and * by 3
        System.out.println("The result is " + (val1 + val2) * 3 );
    The error message is "Error parsing output, please try again"
    Thanks In advance.
    Edited by: Conor O'Neill on Mar 16, 2009 4:11 PM

    >
    Conor O'Neill wrote:
    > Hi Ayyapparaj
    >
    > Thanks for getting back to me: yes I already have done what you suggested and it works fine, but I'm trying to output in an HTML page (in a table).
    Hi,
    What you mean by HTML page(in a table)?
    Code what you have written above is a pure application that need to be run in the way i have mentioned above.
    If you are interested to create a HTML page where you can enter two numbers and print their out put. You need to change the code altogether.
    Regards
    Ayyapparaj

  • Compact output of pacman -Qi(e) showing only prog,desc,size 1 per line

    /* ================================================================================================
    REVISED May 14, 2009
    REWRITTEN - to check for buffer overuns
    Dumb utility which takes the output of pacman -Qi(e) and creates a tab delineated text file
    showing the program name, description and file size, one program per line to be read
    with a text editor or spreadsheet.
    compiling -> q++ qi.cpp -o qi
    Program can be run either as:
    qi // which creates:
    pacQi.txt // output of pacman -Qi > pacQi.txt
    pacQi.xls // tab delineated text file of all installed programs.
    or
    pacman -Qie > somefile
    qi somefile // which creates
    somefile.xls // A tab delineated text file of explicitly installed programs
    ==================================================================================================== */
    #include <iostream>
    #include <fstream>
    #include <stdlib.h>
    #include <cstring>
    #include <string>
    using namespace std;
    string formatstr(const string ="", char=' ' , int prec=0, int strlength=0 );
    int findString ( string, string );
    string padString ( string, int,char = ' ') ;
    const int progWidth = 25 ;
    const int descWidth = 60 ;
    const int sizeWidth = 25 ;
    const int cstring_buffer = 100;
    int main(int argc , char * argv[])
    char ch ;
    unsigned int findPos=0, start, len ;
    char sourceFileName[cstring_buffer];
    char targetFileName[cstring_buffer];
    string strLine;
    string progName, progDesc, progSize;
    if (argc == 1 ) // no arguments provided creates pacQi.txt
    strncpy(sourceFileName,"pacQi.txt", 12);
    strncpy (targetFileName, "pacQi.xls",12 );
    system ("pacman -Qi > pacQi.txt");
    else // user supplied name
    len = strlen(argv[1] ) + 6 ;
    if (len > cstring_buffer )
    cout << "\n\nProgram Exiting to Prevent Buffer Overrun\n\n";
    exit (0);
    //cout << endl << argv[1]<< " length is : " << strlen(argv[1]) << endl; // testing
    strncpy (sourceFileName,argv[1], strlen(argv[1]) + 2 ) ;
    strncpy (targetFileName,argv[1], cstring_buffer - 10 ) ;
    strncat (targetFileName,".xls",5);
    ifstream ifile (sourceFileName) ;
    ofstream ofile (targetFileName) ;
    progName ="";
    progDesc = "";
    progSize = "";
    while (ifile.good() )
    getline(ifile,strLine);
    findPos = findString ("Name", strLine); // Find Name Line
    if (findPos > 0 )
    for (start=findPos+2; start < strLine.size();start++)
    ch = strLine[start];
    progName = progName + ch;
    progName = padString(progName,progWidth);
    progDesc=""; // remove remants of progDesc second line
    progSize="";
    findPos = findString ("Size", strLine); // Find Size
    if (findPos > 0 )
    for (start=findPos+2; start < strLine.size();start++) // kill trailing K
    ch = strLine[start];
    if ( ( (ch >= '0') and (ch <= '9') )or (ch == '.') )
    progSize = progSize + ch;
    string temp;
    temp ="";
    progSize = formatstr(progSize, ' ' , 3, 25);
    findPos = findString ("Description", strLine); // Find Description
    if (findPos > 0 )
    for (start=findPos+2; start < strLine.size();start++)
    ch = strLine[start];
    progDesc = progDesc + ch;
    progDesc=padString(progDesc,descWidth);
    if (progName>"" and progDesc>"" and progSize>"")
    ofile << progName << '\t' << progDesc << '\t' << progSize <<endl ; // Print program record
    progName ="";
    progDesc = "";
    progSize = "";
    } // while loop
    ifile.close();
    ofile.close();
    } // E N D M A I N
    //==================================================================================
    int findString ( string source, string target) // if source found returns ":" + 2
    int found;
    string test;
    test = source;
    found = target.find(source);
    if (!found )
    found = target.find(":");
    if (found < 0 )
    found =0;
    return found;
    //========================================================================
    string padString ( string str, int num, char ch)
    string temp;
    int len;
    temp = str;
    len = str.size();
    for (int start = len; start < num; start++)
    temp += ch;
    return temp;
    //===========================================================================
    string formatstr(const string str, char leadchar, int prec, int strlength)
    using namespace std;
    int i1,i2,len;
    int sptr,tptr,wholeDigits=0,fracDigits=0;
    int fracPtr=0;
    int noc,commaptr; //Number Of Comma's
    bool hasDec=false, isNeg =false;
    string temp,temp2,fracStr,wholeStr,s;
    s=str;
    len=s.size(); // Length of String w/o '-' sign
    temp="";
    if (str[0]=='-')
    isNeg=true; // If negative kill minus sign
    for (int i1=1;i1< len ; i1++ ) // Copy rest of string to s
    temp=temp + str[i1];
    s = temp;
    len=s.size();
    for (sptr=0;sptr <len;sptr++) //Find # of digits wholeDigits + in decimal
    if (s[sptr]!='.')
    wholeDigits++;
    else
    fracPtr=sptr;
    hasDec=true;
    wholeDigits=sptr ; // Represents digits before dec since sptr is at dec. don't increment
    fracDigits = (len-(fracPtr)); // Back into # of decimal digits
    break;
    fracStr="";
    if (hasDec)
    for (i1=fracPtr;i1<len;i1++) // Build fracStr
    fracStr=fracStr + s[i1];
    temp = ""; // bugaboo caused by negativity
    for (sptr=wholeDigits-1,tptr=0; sptr>=0 ;sptr--,tptr++ ) //Reverse wholeDigitsing w/o decimal
    temp= temp + s[sptr];
    temp2=""; // commatize reversed string to temp2
    commaptr=0;
    noc = temp.size() / 3 ; // S E E IF W O R K S
    for (sptr=0;sptr<wholeDigits;sptr++)
    if (commaptr==3 && noc)
    temp2=temp2 + ',';
    noc--;
    commaptr=0;
    temp2=temp2 + temp[sptr];
    commaptr++;
    temp=""; // Reverse commatized Reversed String (wtf)
    for (sptr=temp2.size() -1 ; sptr >= 0 ; sptr--)
    temp = temp + temp2[sptr];
    s=temp;
    len =fracStr.size();
    if (prec < 0)
    ; // Put string back
    if (prec == 0 ) // Leave out fractional part
    fracStr="";
    if (prec > 0 )
    temp="";
    if (fracDigits > prec) // Will Truncate decimal not round up
    for (int i1=0;i1<=prec;i1++)
    temp=temp + fracStr[i1] ;
    fracStr=temp;
    if (fracDigits < prec +1 && len >0) //fractDigits include '.'
    for (int i1=1;i1< (prec-len+2);i1++)
    fracStr=fracStr + '0';
    if(len==0)
    fracStr='.';
    for (int i1=1; i1 <= prec; i1++)
    fracStr = fracStr + '0';
    s=s+fracStr;
    temp = " " ;
    temp[0]=leadchar;
    temp= temp + s;
    if (isNeg)
    temp = '(' + temp + ')';
    i1=temp.size();
    temp2="";
    if (strlength > 0 ) // Pad String for strlength
    i2=strlength -i1;
    for (i1=0;i1<i2;i1++)
    temp2=temp2+' ';
    temp = temp2 + temp;
    s = temp;
    return s;
    Last edited by ljshap (2009-05-14 16:53:51)

    Daenyth wrote:If you're using C, why not either use libalpm instead of system(pacman...), or add the functionality to pacman itself (-Qqi)?
    I never heard of libalpm, but I'll look into for my own information.
    If I added the functionality to pacman itself (assuming i knew how), I would have to change the source and recompile every time there was an update.  My program should work with new versions unless there is a major change to the output of pacman -Qi(e).
    My "program" produces the following output format:
    52dec                              liba52 is a free library for decoding ATSC A/52 streams.                          207.860
    aalib                                AAlib is a portable ASCII art GFX library                                                           824.000
    abiword                           A fully-featured word processor                                                                 12,833.000
    abiword-plugins            Various plugins for Abiword                                                                           4,199.000
      It can be read with a regular text editor or a spreadsheet where it can be sorted by size if you want to see whats taking up hardrive space without scrolling through the detailed output of pacman -Qi.
    Obviously, the program has extremely limited usefullness unless you just want to to see installed programs, it description and size in a more compact format either out of curiousity or your planning on reinstalling but want to see the descrition as well as the program name.
    I appologize if this functionality is already available in libalpm or elsewhere, but I figured I'd put it up in case anyone wanted it.
    Thanks for the additional information.

  • [Solved] Parsing findmnt output?... Is it reliable/portable in bash.

    Solution/better suggestion in second post...
    There seems to be little about using anything other than the output of mount or fstab when dealing with filesystems in scripting. Most of what I've read on it uses awk or cut for parsing "mount" but what about findmnt when needing  some of the same info. particularly "findmnt -rn" which prints the same raw information as mount but space separated and without the words like "type" and "on". I'm not entrirely concerned with posix compliance as most of it amount to makings it compatible with much much older systems. Personally I think bash has been around long enough to be portable in and of itself in most circumstances but that's just my opinion. Is "findmnt" as portable as "mount" for scripting? that is really my question.
    An example would be say I wanted only the "target" and "source" information stored with process substitution in bash.
    with mount I could use
    #mount | cut -d ' ' -f 1,3
    to get that info for all mounted filesystems
    OR
    #mount | grep sdb1 | cut -d ' ' -f 3
    to get where a particular partition (/dev/sdb1) is mounted.
    with findmnt it would be just as simple but take the words "on" and "type" out of the parsing.
    #findmnt -rn | cut -d ' ' -f 1,2
    or for the second example using mount...
    #findmnt -rn | grep sdb1 | cut -d ' ' -f 1
    if neither of these are the best for getting simple information then I can accept other suggestions as well.
    Think of the pipe to grep section having a variable with the needed string instead of "sdb1" for instance...
    maybe this is just a minor formatting discrepancy. If so feel free to point it out... I'm kinda on my journey of do's and don't's in shell scripting with only google and the man pages as my resources for learning.
    Last edited by Thme (2012-12-22 19:55:58)

    falconindy wrote:
    Thme wrote:
    with findmnt it would be just as simple but take the words "on" and "type" out of the parsing.
    #findmnt -rn | cut -d ' ' -f 1,2
    or for the second example using mount...
    #findmnt -rn | grep sdb1 | cut -d ' ' -f 1
    This is an entire misuse of findmnt. If you're going to talk about "portable" or "POSIX", then you can't even use mount.
    If you want specific columns from findmnt, then ask for them. Specifically, the -o option is your friend, i.e.
    $ findmnt -runo source,target /dev/sdb1
    /dev/sdb1 /home
    If you're looking for some absurd level of portability where you might encounter systems that don't have findmnt, then you'll need to build a parser for /etc/mtab, and even that isn't portable.
    That's clear enough to me. And no I wasn't too interested in POSIX compliance. It seems like overkill in most circumstances. As for the findmnt options.. I should have read the man page a little more... totally skimmed over it... I'll mark this as solved...

  • [SOLVED]Need to parse output data

    I have a program that outputs data to the console in this format:
    [1] banana
    [2] orange
    [7] apple
    [17] grape
    [42] strawberry
    I would like to strip this output and only get the values for [2] and [17]. So my output would be:
    orange
    grape
    My first idea was to pipe the output to grep and then possibly use sed to strip the preceding numbers and brackets. What is the recommended way to do this and why? Is there a better suited utility that I'm not aware of?
    Last edited by nadman10 (2013-11-06 16:48:54)

    Trilby wrote:grep + (cut/sed) = awk.
    Very true.
    Trilby wrote: awk '/\[(2|17)\]/ { print $2; }'
    I wanted OP to google / RTFM this himself
    The idea to use sed was correct, nadman10. You should have googled
    remove "square brackets" sed
    and you would have found out the answer yourself: http://www.unix.com/showthread.php?t=159143
    The slightly tricky part with the square brackets is that they have special meaning, so you have to escape them i.e. precede them with '\'.

  • [solved]gcc broken after pacman update - libcloog-isl.2.so

    Hi,
    After a pacman update my gcc broke. When compiling it gives this error:
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/cc1: error while loading shared libraries: libcloog-isl.so.2: cannot open shared object file: No such file or directory
    gcc -v output:
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/lto-wrapper
    Target: x86_64-unknown-linux-gnu
    Configured with: /build/src/gcc-4.6-20111223/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --enable-multilib --disable-libssp --disable-libstdcxx-pch --enable-checking=release --with-fpmath=sse
    Thread model: posix
    gcc version 4.6.2 20111223 (prerelease) (GCC)
    and ls /usr/lib/*cloog* output:
    /usr/lib/libcloog-isl.a  /usr/lib/libcloog-isl.so  /usr/lib/libcloog-isl.so.3  /usr/lib/libcloog-isl.so.3.0.0
    uname -a:
    Linux willem-arch 3.2.4-1-ARCH #1 SMP PREEMPT Sat Feb 4 10:53:01 CET 2012 x86_64 Intel(R) Core(TM) i5 CPU 750 @ 2.67GHz GenuineIntel GNU/Linux
    How can I fix this? I already tried installen cloog with pacman but that doesn't help.
    edit:
    I solved the problem. There was an issue with my pacman.conf. Multilib wasn't properly enabled after the pacman4 transition.
    Last edited by pientertje (2012-02-08 09:47:25)

    I'm using multilib.
    @Allan
    more fully than pacman -Syu? Or is my mirror not up to date?
    edit:
    I solved the problem. There was an issue with my pacman.conf. Multilib wasn't properly enabled after the pacman4 transition.
    Last edited by pientertje (2012-02-08 09:46:40)

  • [SOLVED] HDMI output not working

    I just bought myself a home theater system but can't get my laptop to connect to the reciever.
    My laptop is an Asus UX31E with integrated HD 3000 graphics. When I connect a HDMI cable to the reciever (Pioneer VSX-527) it doesn't even detect my laptop. If I go into the Cinnamon/GNOME display settings, it doesn't even show that I'm connected to an external display.
    In pavucontrol I'm able to select the HDMI as an output, but it doesn't play any sounds on the reciever (which plays just fine from radio, so at least the speakers are connected correctly).
    What to do?
    Edit:
    And here's the output from xrandr:
    HDMI1 disconnected (normal left inverted right x axis y axis)
    Solved:
    Derp, faulty cable.
    Last edited by snufkin (2013-02-06 22:54:37)

    Hi:
    The only suggestion I can offer would be to try the graphics driver from AMD if you have not already done so.
    Your notebook is not supported by HP for W7, and especially not supported for 32 bit operating systems.
    http://support.amd.com/en-us/download/mobile?os=Windows%207%20-%2032
    As a last resort, try manually installing the W7 x64 graphics driver from your notebook's support and driver page (sp66999).
    I explored the driver folder, and there are 32 bit drivers included in that file.

  • [SOLVED] X fails after pacman -Syu

    After a year or so without upgrading (not recommended) I did a pacman -Syu; it took like ages 'cause I was on kernel 2.26, and now my arch is a complete mess: user modules don't load at boot, dhcpcd is not working so I don't have internet access and the X server is erratic too. Now I have to repair it step by step, and I think I should start with X.
    Here is the startx/ xinit output:
    [root@HAL-9000 ~]# startx
    xauth: (argv):1: bad display name "HAL-9000:0" in "list" command
    xauth: (stdin):1: bad display name "HAL-9000:0" in "add" command
    X.Org X Server 1.11.2
    Release Date: 2011-11-04
    X Protocol Version 11, Revision 0
    Build Operating System: Linux 3.1.1-1-ARCH i686
    Current Operating System: Linux HAL-9000 3.1.1-1-ARCH #1 SMP PREEMPT Fri Nov 11 22:05:37 UTC 2011 i686
    Kernel command line: root=/dev/disk/by-uuid/67fb73d6-b981-47d1-a07c-223b5b730551 ro vga=0x0318
    Build Date: 16 November 2011 11:26:40AM
    Current version of pixman: 0.24.0
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
    Markers: (--) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (==) Log file: "/var/log/Xorg.0.log", Time: Sun Nov 20 19:02:40 2011
    (==) Using config file: "/etc/X11/xorg.conf"
    (==) Using config directory: "/etc/X11/xorg.conf.d"
    (EE) synaptics: Touchpad: Synaptics driver unable to detect protocol
    (EE) PreInit returned 11 for "Touchpad"
    gnome-session: error while loading shared libraries: libdevkit-power-gobject.so.1: cannot open shared object file: No such file
    or directory
    xinit: connection to X server lost
    waiting for X server to shut down Server terminated successfully (0). Closing log file.
    I guess the gnome-session error with libdevkit-powe-gobject.so.1 is what causes the x server to close. And this is the complete X log:
    http://pastebin.com/UBficJVi
    *note: I have a Nvdia card which already worked perfectly with the privative driver, and supposedly I still have gnome 2 (that was the only packages group I didn't upgrade)
    Last edited by isacdaavid (2011-11-21 06:27:07)

    isacdaavid wrote:
    knopwob wrote:
    isacdaavid wrote:*note: I have a Nvdia card which already worked perfectly with the privative driver, and supposedly I still have gnome 2 (that was the only packages group I didn't upgrade)
    So you updated everything except gnome-stuff? Update the gnome-stuff.
    But I'm all for gnome 2 , and X should work despite of the gnome version or the desktop environment. Shouldn't it?
    No, not if you're using gdm or autoboot into gnome or something similar.
    gnome-session: error while loading shared libraries: libdevkit-power-gobject.so.1: cannot open shared object file: No such file
    or directory
    This sounds like one of gnome-sessions dependencies have been updated and isn't compatible with gnome-session anymore.
    Before you continue trying to repair your system, you should read this

  • [SOLVED] Parsing simple config files in pure bash

    Hi everyone,
    I'd like to implement a bash function to parse a simple config file for a script I've wrote. The conifg file contains different sections for different scenarios. Here's an example how it should look like:
    # configuration file
    # global settings
    global {
    DATE_PREFIX="-I"
    SSHFS_OPTS="-C"
    EXT_FULL="full"
    EXT_DIFF="diff"
    EXT_CATALOGUE="catalogue"
    DAR_OPTS="-v -m 256 -y -s 600M -D"
    DAR_NOCOMPR="-Z '*.gz' -Z '*.bz2' -Z '*.zip' -Z '*.png'"
    # system settings
    system {
    DAR_OPTS="-v -m 256 -y -s 200M -D"
    It contains some settings which are global for the whole script and special settings groups which can be used to overwrite global settings.
    The function to parse this config file looks as follows:
    #!/bin/sh
    CONFIG="/home/chi/.daruprc"
    function readconf() {
    match=0
    while read line; do
    # skip comments
    [[ ${line:0:1} == "#" ]] && continue
    # still no match? lets check again
    if [ $match == 0 ]; then
    # do we have an open tag ?
    if [[ ${line:$((${#line}-1))} == "{" ]]; then
    # strip "{"
    group=${line:0:$((${#line}-1))}
    # do we have a match ?
    if [[ ${group} -eq $1 ]]; then
    match=1
    continue
    fi
    continue
    fi
    # found close tag but still no match - continue
    elif [[ ${line:0} == "}" && $match == 0 ]]; then
    continue
    # found close tag after config was read - exit loop
    elif [[ ${line:0} == "}" && $match == 1 ]]; then
    break
    # got a config line return it
    else
    echo $line
    fi
    done < "$CONFIG"
    for line in $(readconf "system"); do
    echo $line
    done
    As you can see I try to just echo the lines at the moment. And here's the problem: It seems I have some " escape issues, if I run it I get the following output:
    ./parseconfig.sh
    DATE_PREFIX="-I"
    SSHFS_OPTS="-C"
    EXT_FULL="full"
    EXT_DIFF="diff"
    EXT_CATALOGUE="catalogue"
    DAR_OPTS="-v
    -m
    256
    -y
    -s
    600M
    -D"
    DAR_NOCOMPR="-Z
    '*.gz'
    -Z
    '*.bz2'
    -Z
    '*.zip'
    -Z
    '*.png'"
    As you can see there are way to much newlines - which leads to problems when I try to use "eval" to initialize the variables.
    I am sure I am missing something simple here, however I am looking for a solution for a few days now - maybe one of the bash gurus on this board can enlighten me ;-).
    Thanks in advance
    PS.: I am trying to do this in pure bash because the script also needs to run on embedded machines with very low memory like my router on which I don't have sed or awk or the like. I also know that I could for example just use different config files to circumvent the whole parsing - but I am just curious if this could work the way I like ;-).
    Last edited by chimeric (2007-11-04 23:20:58)

    chimeric wrote:
    Hi MrWeatherbee,
    well yes, but I want to assign (eval) these lines to get variables out of them. Since the while loop is trapped in its' own subshell I need to return the lines into the parent one to be able to make these variables "visible" in the script itself.
    Right. But I was trying to show you that the way you were going about it wouldn't work at a very fundamental level.
    Without changing too much code just for a quick and dirty demo,
    change:
    # got a config line return it
    else
    echo $line
    fi
    done < "$CONFIG"
    # got a config line return it
    else
    line_array=( "${line_array[@]}" "$line" )
    fi
    done < "$CONFIG"
    numarrayelements=${#line_array[@]}
    and then in the main program code, do this:
    readconf "system"
    for index in $( seq $numarrayelements ); do
    line=${line_array[(($index-1))]}
    echo $line
    done
    Using an array to collect the good lines from the function allows you to reuse them later for whatever purpose. Although other ways exist, you certainly don't want to do what you originally did.
    Edit:
    I posted the code with an incorrectly referenced variable and had to fix it.
    Last edited by MrWeatherbee (2007-11-04 22:46:34)

  • [SOLVED ]makepkg asking for pacman-color binary

    After upgrading pacman to 4.1 I'm getting this error every time I run makepkg:
    /usr/bin/makepkg -s -i
    ==> ERROR: Cannot find the pacman-color binary required for dependency operations.
    Even if I try to use --nocolor:
    /usr/bin/makepkg --nocolor -s -i
    ==> ERROR: Cannot find the pacman-color binary required for dependency operations.
    I've tried enabling and disabling color options in both makepkg.conf and pacman.conf, and the error is still there.
    Any clue on what could be going on and how to solve it?
    Thank you in advance
    Last edited by ethail (2013-04-01 23:01:32)

    echo $PACMAN
    pacman-color
    I guess I've forgotten to edit some file that I changed when using pacman-color-testing from the AUR.
    EDIT: Indeed, I forgot to edit my .zprofile that used to export PACMAN as pacman-color. Solved now
    Thank you, Allan
    Last edited by ethail (2013-04-01 23:02:14)

  • [SOLVED] GRUB crashed after pacman -Su

    Hello all,
    I did a system update about 2 hours ago, I did pacman -Syy and pacman -Su. Every thing looked normal.
    Restarted and system crashes right in GRB, it doesn't even shows the menu or error message, it just fills the screen with "GRUB GRUB GRUB GRUB GRUB GRUB GRUB".
    I checked the disk, partition tables are ok, and the whol HD looks ok, no errors at all (checked with system rescue cd, a gentoo live cd).
    I also mounted the boot partition, all files seem to be ok, grub menu, etc..
    /grub/menu.lst was modified today, but looks ok.
    Any Idea of what could happen?
    How to solve it?
    Should I try to replace grub?
    Last edited by iopo (2011-04-28 11:31:34)

    Thank you hcjl and demian.
    Problem solved after GRUB re-install.
    Here is the procedure (resume from hcjl links) I made, just in case someone else needs it:
    1- Download the arch iso and write it to cd or dvd
    2- Run the cd, login as root
    3- Mount arch and boot partitions:
    -Find boot and arch partitions with
    fdisk -l
    Create a directory where you would like to mount the arch partition, then mount it:
    mkdir /mnt/arch
    mount /dev/<device-or-partition-name> /mnt/arch
    4- Changing Root:
    cd /mnt/arch
    mount -t proc proc proc/
    mount -t sysfs sys sys/
    mount -o bind /dev dev/
    Mount the boot partition:
    mount /dev/<device-or-partition-name> boot/
    And change root:
    chroot . /bin/bash
    5- Install GRUB on hd0 (first hard drive):
    # grub
    grub> setup (hd0)
    6- Exit all, reboot
    That fixed my problem, and preserved my original GRUB menu (I did a backup of broken GRUB, but it was nor necesary)
    Thank you all for your help.
    Last edited by iopo (2011-04-28 21:16:47)

  • [solved] yaourt messed up pacman - "pacman: command not found"

    Hi,
    i got some "xxxxxx not found on AUR" messages after doing a "yaourt -Syu --aur" so I began to remove them with "yaourt -Rs xxxxxxx".
    When there was only one left "aqpm2" this is what happened:
    [studio@myhost ~]$ yaourt -Rs aqpm2
    verificando dependências...
    Remover (2): aqpm2-20100615-2  qjson-0.7.1-2
    Tamanho total dos pacotes a serem removidos:   2,93 MB
    Deseja remover estes pacotes? [S/n] s
    (1/2) removendo aqpm2                                                                                                     [##########################################################################] 100%
    (2/2) removendo qjson                                                                                                     [##########################################################################] 100%
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    /usr/bin/yaourt: line 201: testdb: comando não encontrado
    now pacman is broken:
    [studio@myhost ~]$ pacman
    bash: pacman: comando não encontrado
    [studio@myhost ~]$ yaourt -Syu --aur
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    You are not allowed to launch /usr/bin/pacman with sudo
    Please enter root password
    Senha:
    bash: /usr/bin/pacman: Arquivo ou diretório não encontrado
    ==> WARNING: problem in pkgbuild.sh library
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    ==> Searching for new version on AUR
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    Unable to open file: /etc/pacman.conf
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    /usr/lib/yaourt/basicfunctions.sh: line 10: pacman: comando não encontrado
    /usr/bin/yaourt: line 201: testdb: comando não encontrado
    [studio@myhost ~]$ sudo pacman -Syu
    sudo: pacman: command not found
    please help
    Last edited by capoeira (2010-10-16 14:33:39)

    capoeira wrote:
    can I use pacman-static from this repro?
    I'm afraid to break system even more
    http://repo.archmobile.org/x86_64/archmobile/
    OK, that gave me a segfault, so
    I downloaded the package and copied the folders to root.
    no pacman works but gaves me this errors afterwards:
    pacman-3.4.1-1: description file is missing
    pacman-3.4.1-1: dependency file is missing
    pacman-3.4.1-1: file list is missing
    how do I solve this?
    BTW: should I make a bug-report??
    EDIT: any package I try to instal I get this error:
    erro: não foi possível abrir o arquivo /var/lib/pacman/local/pacman-3.4.1-1/depends: Arquivo ou diretório não encontrado
    (it's in portuguese but i think its understandable)
    Last edited by capoeira (2010-10-15 22:08:36)

  • [SOLVED] can't upgrade pacman: bluez and obexd-client are in conflict.

    sorry for the newbie question but I can't find a solution and am unable to update my arch.
    ]# pacman -Syu pacman
    :: Synchronising package databases...
    core is up to date
    extra is up to date
    community is up to date
    multilib is up to date
    archlinuxfr is up to date
    :: The following packages should be upgraded first :
    pacman
    :: Do you want to cancel the current operation
    :: and upgrade these packages now? [Y/n] n
    :: Starting full system upgrade...
    :: Replace gummiboot-efi with core/gummiboot? [Y/n] n
    :: Replace libsoup-gnome with extra/libsoup? [Y/n] n
    :: Replace webkitgtk3 with extra/webkitgtk? [Y/n] n
    resolving dependencies...
    looking for inter-conflicts...
    error: unresolvable package conflicts detected
    error: failed to prepare transaction (conflicting dependencies)
    :: bluez and obexd-client are in conflict
    does anyone know how to solve this?
    Last edited by crashandburn4 (2013-06-30 03:47:05)

    hi, really sorry as I said I'm somewhat of a newbie, was waiting to see what you guys thought might be relevant so I could tell you what I've got, here goes:
    graphics card: nvidia geforce GTX660.
    DE/WM (I assume is desktop environment): gnome
    unsure about how I start X (sorry I understand I am a newbie)
    oh and everything does seem to be hanging, ctrl-c does nothing.
    there were no messages from the update, I checked pacman and didn't see any warnings, (is there any kind of log I can check in case I missed something?), I've chrooted into the disk through the installation medium to reinstall the graphics card drivers (as suggested here https://bbs.archlinux.org/viewtopic.php?id=153206)
    Last edited by crashandburn4 (2013-06-30 01:05:39)

  • [Solved] How to reduce "Pacman -Qe" result by dependency?

    I know "Pacman -Qe" will list which all package I explict installed.
    But, I want to reduce the result by dependency.
    For example:
    If I've install xpdf & xpdf-Chinese.  I want to reduce the report to xpdf-Chinese.
    Because there is a dependency of xpdf in xpdf-Chinese.
    Ans: pacman -Qt
    Thank you, it works.
    Last edited by dlin (2011-02-28 14:03:00)

    I think this is what you want:
    -t, --unrequired
    Restrict or filter output to packages not required by any currently installed package.

  • [SOLVED] Xscreensaver outputs log text above active screensaver

    I'm having problems understanding why this happens. Running the latest xscreensaver and whenever I choose to preview or run a screensaver I get an ugly yellow log-like output either in background or foreground of the active screensaver. Only using
    xscreensaver-demo
    to change settings and starting the xscreensaver daemon from my ~/.xinitrc. A screenshot:
    I've had this problem for a while, so if you people have an idea please share it. Thanks!
    Last edited by hesse (2012-01-03 15:39:53)

    Problem solved: had to change the following X resource setting in ~/.Xresources from true to false:
    xscreensaver.verbose: false
    . Never mind!

Maybe you are looking for

  • Automatic PO Creation thru assign PR to source of supply (me57)

    Hello, I'd like to have an automatically created PO out of my PR thru ME57. I assign the PR to a source. and press the nice button for generate PO. But then it doesn't generate the PO, it just shows me the me21n with the PR in the document overview i

  • ICloud and selective downloads (iCloud for a Family 2!)

    I haven't yet updated to iOS 5 because I don't know how to manage our account for a Family, and any help would be greatly appreciated. Presently, we have a single iTunes account linked to my desktop Apple. On it are my wife and I and 2 children. We a

  • IMac Airport continues to drop connection

    I seem to be having the exact same issue that many of you have.  My iMac is the only piece of hardware in my house that has this issue.  The iMac will randomly drop its internet connection.  If you turn off airport and back on it will reconnect just

  • Remove grid lines when printing

    I am trying to print a set of financial statements and do not want to see the grid lines when printing the final document. I cannot work out how to do this. Some posts I have read say that grid lines are described as cell borders and suggest that the

  • Copy a cd or dvd

    Can anyone tell me how I can make a copy of a cd or dvd? I have the super drive.