Skip to content

List integer PIDS from the '/proc' directory in Linux with some formatting options.

License

Notifications You must be signed in to change notification settings

Lateralus138/lspids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

List PIDS lspids logo

  1. About
    1. Description
    2. Motivation
  2. Usage
    1. Environment
      1. Files
      2. Current Builds MD5
        1. Current Linux MD5
        2. Current Debian MD5
        3. Current Android ARM32 MD5
        4. Current Android AARCH64 MD5
      3. Project Information
    2. Debian Installer
      1. Deb Install
      2. Deb Provides
        1. Bash Completion
        2. HiColor Icon Theme
        3. Man Page Entry
    3. Portable
    4. Android
    5. Build Yourself
      1. Dependencies
      2. Build Command
    6. Bash Completion
    7. Examples
      1. Help Screen
      2. Normal Usage
      3. List in a null terminated list
      4. List in a tab delimted list
  3. Media
    1. Logo
    2. Screenshots
      1. Help Screen
      2. Main Examples
      3. Man Page
  4. Contribute
    1. Project
    2. Donate
  5. LICENSE

Twitter URL


About

Description of and information about this project.

Description

List integer PIDS (process identification numbers) from the '/proc' directory in Linux (and Android - Termux) with some formatting options.

Motivation

I do a lot with pids across all operating systems (as with most computer oriented people) and I often need a quick list or array of said pids with various formatting and this program provides these features in a quick and simple manner.


Usage

When, where, and how to use this program.

Environment

This is an open-source (FOSS) command line utility for use in Linux and Android shells (terminals/ttys/Termux/etc.). This can be built from source (as per the LICENSE file provided), used portably (single executable put wherever you like), or installed via the provided Debian (.deb) package.

The recommended method of use is via the Debian package installation for the Debian (apt, deb) packager manager, but there are other methods provided here or if you would care to provide an installer for a different package manager then please fork this project, build the appropriate workflow and source files, and make a pull-request. More information about contributing here.

Files

All currently built and released files can be found at the releases page:

Releases

Current Builds MD5

This information is generated in a GitHub Action immediately after the successful build of this project.

Current Linux MD5

Linux MD5

Current Debian MD5

Debian MD5

Current Android ARM32 MD5

Android ARM32 MD5

Current Android AARCH64 MD5

Android AARCH64 MD5

Project Information

Code Factor IO grade from combined source files and workflow scripts in this project (currently 7 files).

Current CPP

Debian Installer

I personally recommend this method as it automatically installs a basic Bash Completion file, a hicolor icon theme, and a man page entry.

Deb Install

  1. Download and install the current .deb installer file at the releases page.
  2. Use one of various command line tools to install the package:
    1. APT
    sudo apt install /path/to/lspids-1.0.0.deb -y
    # -y to skip affirmation, not necessary
    1. DPKG
    sudo dpkg -i /path/to/lspids-1.0.0.deb
    1. GDEBI
    gdebi-gtk /path/to/lspids-1.0.0.deb
    # or
    sudo gdebi /path/to/lspids-1.0.0.deb

Deb Provides

The deb installer provides a few features (among providing a way to cleany install and uninstall all features):

Bash Completion

The Bash Completion File provides basic Bash completion for switches and parameters and is installed to /usr/share/bash-completion/completions/lspids when installed with the deb package.

More infomation can be found here:

Bash Completion

HiColor Icon Theme

The deb package installer provide an icon theme for HiColor in case you want to make a .desktop shortcut or anything else. Icons are installed to /usr/share/icons/hicolor/{16,32,48,64,128,256}/apps/lspids.png.

lspids logo

Man Page Entry

The manual page is a more advanced verion of a Help Message and can be accessed from the command line via: man lspids.

 $ man lspids
...
NAME
       lspids - List PIDS from the `/proc' directory in Linux

SYNOPSIS
       lspids [OPTIONS [PARAMETER]]...

DESCRIPTION
       List integer PIDS from the `/proc' directory in Linux with some formatting options.

OPTIONS
       -h, –help
              This HELP message.

       -0, –null
              Output is null terminated.  If this switch is enabled before delimiter is set then you can still delimiter the output.

       -d, –delim
              Set a string delimiter to separate output.  Defaults to a new line, but can be any string.

EXIT CODES
       0      No errors.

       1      Too many options passed to the program.

       2      `/proc' doesn’t exist.

       3      `/proc' is not a directory.

       4      Could not iterate `/proc' for an unknown reason.

       5      No option provided for the given argument.

AUTHORS
       Ian Pride.

lspids - 1.0.0                                                     Sat 09 Jul 2022 07:51:17 PM UTC                                                          LSPIDS(1)

Portable

You can use this portably by downloading the lspids executable bin file from the releases page and putting it anywhere you like; most preferably in one of your $PATH (echo $PATH) directories.

As with any executable file in most operating systems if this is not installed to $PATH then you must provide the full path when you run it. If it is in your $PATH then you can just run it with the file name.

 # In $PATH
 $ lpsids --help
 # Not in $PATH
 $ /full/or/relative/path/to/lspids --help

Android

The Android executables (.arm32 and .aarch64) are portable and should probably be installed to /data/data/com.termux/files/usr/bin/lspids (removing the extensions if you like) and you must have root access. I plan to build a deb installer in the future.

Build Yourself

You can, of course, build this yourself the from source located in the linux directory of this repository. You can download the whole project in a compressed archive from the current releases page.

Extract the project to wherever you want to build:

tar -xvzf /path/to/lspids-1.0.0.tar.gz -C /path/to/where/you/want/to/build 

I created and use a custom Makefile system not reliant on CMAKE and only reliant on GNU++17/MAKE, but it shouldn't be too hard to figure out. I build objects from src/include to a lib archive src/lib in and build with -Lsrc/lib and -llib<BIN NAME>.a.

Dependencies

All packages you will need to build this:

make, g++[4:9,gnu++17], build-essential, binutils

which you can install in with APT in a Debian based system:

sudo apt install make g++ build-essential binutils -y

Build Command

Run make first to test; no ./configure:

make

and if successful; install and clean (need to fix the regular and all build):

sudo make releasedynamicall install && sudo make clean

Bash Completion

Bash completion can be provided by placing the lspids Bash completion file to /usr/share/bash-completion/completions. This is already done if installed with a package manager.

lspids Bash Completion File:

lspids_list=(
  -h --help
  -0 --null
  -d --delim
)
complete -W "$(printf '%s\n' "${lspids_list[@]}")" lspids

Examples

Help Screen

 $ lspids --help
┌────────────────────────────────────────────────┐
│ lspids - 'List PIDS'                           │
├────────────────────────────────────────────────┤
│ Usage: lspids [OPTIONS [PARAMETER]]...         │
│   List integer PIDS from the '/proc' directory │
│   in Linux.                                    │
├────────────────────────────────────────────────┤
│ OPTIONS: switches and arguments                │
│   -h,--help     This HELP message.             │
│   -0,--null     Output is null terminated. If  │
│                 this switch is enabled before  │
│                 delimiter is set then you can  │
│                 still delimiter the output.    │
│   -d,--delim    Set a string delimiter to      │
│                 separate output. Defaults to a │
│                 new line, but can be any       │
│                 string.                        │
├────────────────────────────────────────────────┤
│ Exit Codes: Error codes and their meanings.    │
│   0   No errors.                               │
│   1   Too many options passed to the           │
│       program.                                 │
│   2   '/proc' doesn't exist.                   │
│   3   '/proc' is not a directory.              │
│   4   Could not iterate '/proc' for an unknown │
│       reason.                                  │
│   5   No option provided for the given         │
│       argument.                                │
└────────────────────────────────────────────────┘  

Normal Usage

 $ lspids
...
1641
1655
1665
1666
1667
1691
1697
1701
1703
...
 $

List in a null terminated list

  $ lspids -0 # or --null
...241 247 251 252 253 260 274 275 323 343 344 349 357 362 379 390 391 392 393 429 430 433 461 462 494 535 536 537 538 539 540 541 542 544 545 548 574 575 576 577 589 631 798 812 834 838 839 847 848 849 850 851 852 853 854 855 856 857 858 911 916 917 918 944 958 959 960 963 1004 1005 1009 1011 1015 1016 1017... $

List in a tab delimted list

 $ lspids -d $'\t'
...2160    2162    2163    2173    2175    2179    21962198     2206    2209    2221    2222    2223    2230    2235    2249    2272    2284    2656    2687    2708    2710    27122717     2725    2734    2738    2744    2754    2756    2769    2772    2774    2776    2778    2786    2795    2800    28052824     2828    2831    2843    2850    2854    2863    2880    2901    2904    2915    2951    3007    3012    3023    30303051     3056    3100    3128    3129    3130    3131    3132    3133    3137    3138    3142    3144    3149    3151    31543156     3158    3293    3691    3695    3698    3708    3719    3837    3841...
 $

Media

Logo

LOGO

Screenshots

Help Screen

HELP SCREEN

Main Examples

MAIN EXAMPLES

Man Page

MAN PAGE


Contribute

Ways you can help if you like.

Project

You can fork this project, make your contributions, and make a pull-request.

Donate

If you like this project and care to donate to my PayPal:

PayPal Donation

Or Buy Me A Coffee if your prefer:

Buy Me A Coffee


License Info

License Excerpt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

About

List integer PIDS from the '/proc' directory in Linux with some formatting options.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages