Skip to content

Lateralus138/onlyonev2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OnlyOne V2

Logo


Description

Get unique lines from a file, piped stdin, or passed arguments in the command line. This is version 2, a complete re-write in a different language.


Table Of Contents


Support Me If You Like

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


About

Version 2

Reason For V2

This version, officially Version 2, is a C++ re-write of my RustLang command line program of the same name. I needed to add a way to process different types of input (stdin from pipe, file, and/or passed args) as the original only accepts lines from a file.

Since I'm far more experienced with C++ and have just barely learned Rust then C++ is the more viable option for me at this point.

New In V2

  • Added the ability to accept all manner of standard input rather than only just a file.
    • Input types
      • FILE - any readable file
      • PIPE - output from from another command
      • ARGS - any string passed to the program not attached to a switch (e.g. -f FILE).
    • As the name of the program implies this only prints one unique line from all inputs.
  • Created an Android build and release.

Motivation

  • I wanted a better solution than |sort|uniq to get unique lines from a file. I use this to truncate files like .bash_history (especially since I use fzf to search history).
  • I like to make my own utilities even if there are viable alternatives.
  • I needed to add more features

Usage

Environment

This is a command line tool that should work in any shell/terminal/console/tty in several operating systems.

Installation

This is a portable application with no dependencies, but the Linux version has a deb package installer that provides simple Bash Completion and some icons for hicolor. If it is not installed it should be placed in your PATH in your respective environment. if you don't put in a PATH then you will have to run it directly, of course.

Your PATH's can be found in your respective variables per your operating system (of course, you might've added your own directories to the PATH:

Linux, Android, and Mac OS Path

echo $PATH
# or
printf '%s\n' $PATH

Windows Path

PowerShell

Write-Host $Env:PATH

Android Installation

Sorry that I don't have this in a PPA, but the best method to install this in Android for Termux (or other) if you're not rooted is to copy it to /data/local/tmp/ using adb or copy it to your SD card and use Termux to copy it to where from where ever you can.

If you're rooted you can do whatever you like, same Linux method (no deb).

CMD

echo %PATH%

Examples

Various simple examples that work in all operating systems provided.

Windows Examples

PowerShell:

$lines =
  "Line A",
  "Line A",
  "Line B",
  "Line B",
  " Line C",
  "Line C",
  "line c",
  "LINE C"
# Not in path
$lines | '.\Path\To\onlyone.exe'
Line A
Line B
 Line C
Line C
line c
LINE C
# In path
$line | onlyone --insensitive
Line A
Line B
 Line C
Line C

Everything Else Examples

# Not in path
cat ~/.bash_history | wc -l
2245
/path/to/onlyone --file ~/.bash_history | wc -l
1333

# In path
# Reduce line length of .bash_history and backup.
onlyone -f ~/.bash_history >> ~/.bash_history.unique &&
cp ~/.bash_history ~/.bash_history.backup &&
mv ~/.bash_history.unique ~/.bash_history

Help Screen

                                                  
 'OnlyOne' - Get unique lines from a file, piped  
 stdin, or passed arguments in the command line.  
                                                  
 USAGE:                                           
     onlyone <OPTIONS <PARAMETER>> <ARGUMENT>     
                                                  
 OPTIONS:                                         
     -h, --help          This help message.       
     -i, --insensitive   Tests are case           
                         insensitive.             
     -f, --file          Add the lines of a       
                         <FILE> to the queue.     
                                                  
 PARAMETER:                                       
     FILE:   Path to a file to read line by line. 
                                                  
 ARGUMENT:                                       
     LINES:  Additional strings passed directly   
             to the program delimited by a space. 
             Wrap the strings in quotes for proper
             formatting.                          
                                                  
 ERRORS:                                          
     1   Not enough parameters passed to FILE.
     2   FILE does not exist.                 
     3   FILE is not a regular file.          
     4   Could not open FILE.                 
                                                  

Project Information

This project is written in C++.

C++

Readme Card

Description Status
Project Release Date GitHub Release Date
Total downloads for this project GitHub all releases
Complete repository size This Repo Size
Commits in last month GitHub commit activity
Commits in last year GitHub commit activity

Latest Version Status

Description Status Number of Downloads
Latest Release version Release Version GitHub release (latest by date)
Latest Tag version, possible Pre-Release's Tag Version GitHub release (latest by date)

File Information

All current compiled files and the source of this project can be found at this repository in the Releases section under Stable Release and can be found in 32 (X86) and 64 (X64) bit format for Windows and 64 bit otherwise.

You may want to rename any of the provided executables to onlyone (or onlyone.exe).

This is the recommended method of download.

CR

You can, of course, build, fork, and/or download the source of this project as per the LICENSE of this project. If you want me to create a build for a different architecture and don't want to do it yourself then just let me know what you need and I'll look into it.

MD5

These MD5 values are evaluated immediately after the build.

Windows X86 MD5

X86 MD5

Windows X64 MD5

X64 MD5

Linux MD5

Linux MD5

Debian MD5

Debian MD5

Android MD5

Android MD5

MacOs MD5

MacOs MD5


Media

Logo

A simple little logo I created in Glimpse (new version of GIMP).

This is in the Windows executables and is installed with the hicolor theme with the Linux .deb installer.

Logo

Help Screen

Help Screen

Silly Example

Silly Example


License Info

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

Get unique lines from a file, piped stdin, or passed arguments in the command line.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages