getgle / getgle-coreutils Goto Github PK
View Code? Open in Web Editor NEWThe Unix Coreutils in PHP :^)
License: GNU General Public License v3.0
The Unix Coreutils in PHP :^)
License: GNU General Public License v3.0
Hi getgle/get52, when looking at the manual of cat there are a bunch of options that cat provides that your php rewrite of cat does not provide.
-A, --show-all
equivalent to -vET
-b, --number-nonblank
number nonempty output lines, overrides -n
-e equivalent to -vE
-E, --show-ends
display $ at end of each line
-n, --number
number all output lines
-s, --squeeze-blank
suppress repeated empty output lines
-t equivalent to -vT
-T, --show-tabs
display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting
use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version
output version information and exit
I tried to write in cat in python (I don't know how to code in PHP) and made some of these options. A lot of them are useless but the main actually usefule ones I think are being able to see a concatenated version of multiple files and being able to see a line count.
https://codeberg.org/zortazert/Python-Projects/src/branch/main/gnu/pof.py
# POF - Print Out Files
import sys
import os
args = sys.argv[1:]
special = ["-n", "-b",]
if args == []:
print("No arguments were given")
quit()
if "-h" in args:
print("""Usage:
- python pof.py [FILE]
Print out contents of given file (if they exist)
- python pof.py [FILE] [FILE2] [FILE3]
Print out all given files (if they exist)
- python pof.py -n [FILE]
Print out numbered the lines in the file.
- python pof.py -b [FILE]
Print out numbered only blank lines in the file.
- python pof.py -h
Pring out this help""")
quit()
num=0
for arg in args:
if os.path.isfile(arg):
with open(arg) as f:
if "-n" in args:
for line in f.read().splitlines():
num = num+1
print(num, line)
elif "-b" in args:
for line in f.read().splitlines():
if line == "":
print(line)
else:
num = num+1
print(num, line)
else:
print(f.read())
elif arg in special:
pass
else:
print(f'Can not find "{arg}"')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.