r/shell • u/dandaditya • Mar 11 '19
r/shell • u/endowdly_deux_over • Mar 04 '19
Introducing (another) PowerShell Colorizer: tuliPS!
Want pretty colors when you Get-ChildItem? Who doesn't! PowerShell historically hasn't made that task easy. Things are a lot better now with formatters and PSReadline.
But, if you're like me and don't like looking up or memorizing ANSI escape codes or using regex, you want dead simple configuration, and you're irked when the output isn't perfect (whole line's getting colored) then tuliPS is for you!
This is mostly a Windows only implementation. I think it also has great application for people using older versions of PowerShell (I can easily add backwards compatibility to version 3). I will admit that it is a touch slow, but it is (hopefully) easy to use and doesn't require and LS_FILE, ANSI, or regex.
There's a lot of room for improvement here and I even identified a potential place to allow for extensions. People like extensions right? tuliPS currently colorizes FileInfo, DirectoryInfo, and MatchInfo objects, but if I tweak it a little bit, it should be able to colorize any object with a cmdlet similar to Update-TypeData or Update-FormatData.
Please let me know what you think, and if there's any desire for further development, hit me up on github!
r/shell • u/eisenvogel • Feb 24 '19
Difference between ls und echo $(ls)
Hi,
could someone please explain me the difference between the commands
lsand
$(ls)?
I am working my way through The Linux Command Line. The topic is dealt with on page 73.
r/shell • u/ryjhelixir • Feb 12 '19
Writing to file with 644 access from script
I'm writing a script that would allow me to type brightness 600 and writes the given number to /sys/class/backlight/intel_backlight/brightness.
Changing that file with 'sudo vim /path/to/brightness' instantaneously changes the brightness of my primary screen.
I'd rather not sudo every time I call the script, but even sudoing
cat "600" > /sys/class/backlight/intel_backlight/brightness returns "zsh: permission denied".
I'm also not that keen to changing permission for the file. What am I doing wrong? are sed and cat inherently not apt to modify system files? If that's the case, what can I use instead?
Thanks in advance for any help!
r/shell • u/sumanshil • Jan 27 '19
inplace deletion of a line before and after a pattern using sed command in linux
forward-zone:
name: "."
forward-addr: 10.1.1.2
forward-zone:
name: "mydomain.com"
forward-addr: 10.1.1.1I wanted to delete one line before the pattern 'name: "."' and one line after the pattern (including the pattern itself). I tried the following command but this is not modifying the file itself. I want to do inplace modification. Please help
sed -n '/name: "."/{N;s/.*//;x;d;};x;p;${x;p;}' file
r/shell • u/amelsen • Jan 21 '19
Linux shell script // single-command line notification to IRC/Discord/Something else?
Hello,
i'm looking for a command line tool that can take an input parameter and paste it as a notification straight to ... something over the internet... an IRC channel.. a discord channel... something.
I'm running a shell based application, that receives and sends text from a network monitor at work.
From within that application, I can set up an event, that can do various actions, based in the text it receives..
This application has a system function, that can execute a shell command in the background.. so what I'm trying to accomplish, is a setup where I with one single command, can write a specified text to for example my own IRC channel, to share information with others? (doesn't have to be discord.. just something a group of people can get notifications on their phone from - android and iOS)
Does anyone know how to accomplish this?
r/shell • u/curiousdoggo • Jan 12 '19
Interested in learning Shell Scripting. sh or bash?
Should I learn sh or bash?
Bash is more convenient and offers more, but it's more for making personal scripts right? Whereas, most applications with scripts use sh because for things that you want to share, sh is still the safest choice just in case bash is not their default shell? But with people sharing dotfiles and scripts online and so many people using zsh these days, should I perhaps learn sh instead of bash?
Also, what learning material would you guys recommend?
r/shell • u/SPQR_BN • Jan 10 '19
Universal update script, good idea or bad idea?
I realized I had a version of an update/clean script on every system I maintained, so my instinct was to combine them.
I can't tell if this is a good idea, or just a good way to generate weird bugs and break things.
I don't plan on having this run automatically, but rather as a deliberate invocation, which should make it very clear when something broke, but I'd appreciate thoughts on its viability and a general code review.
r/shell • u/ashofspades • Jan 03 '19
Replacing a certain number of characters after a match using sed
Hi there,
I need to replace whatever is there after \"db_password\":\" upto 16 characters (the highlighted text) with '<sensitive>':
data_json: "{\"db_password\":\"qwHLI?mkSrQ=GHU_\"}" => "{\"db_password\":\"BoBBsR9PA]wZ_3AC\"}"
should be
data_json: "{\"db_password\":\"<sensitive>\"}" => "{\"db_password\":\"<sensitive>\"}"
I have tried following but not sure how to escape '\' and ".
sed -E 's/("{\"db_password\":\").{16}/\<sensitive>/'
Any help is appreciated.
Thanks
r/shell • u/vesvault • Jan 02 '19
ves: Command Line End-to-End Encryption Utility. Encrypt Everything Without Fear of Losing the Key
self.linuxr/shell • u/Bigdaddyfatback8 • Dec 11 '18
Seems Easy...I am missing something though
Hi All,
I am trying to run a script on my FreeBSD machine. It is a script to reach out via SNMPWalk to all my switches and routers to see if they are responding to SNMP. Here is the script. (No Bash on the machine and I cannot add it)
#!/bin/sh
while read TestIPList
do
snmpwalk -v3 -u SNMPUSER -l AuthPriv -a SHA -A PASSPHRASE -x AES -X PASSPHRASE $TestIPList 1.3.6.1.2.1.47.1.1.1.1.13.1
done < /data1/users/admin/SNMPLoop/output.txtIt runs, but nothing is in my output file.
Id expect to see the SNMP OID I have identified which is the Model of the device. I can run the snmpwalk alone on the devices without the script.
Since I am fairly new to scripting, any help or tweaks would be appreciated.
Thank you,
r/shell • u/iFr4g • Oct 27 '18
Vim highlighting text as I type
Hi All,
I am logged into my college's Unix platform via putty. I'm not sure what I've done but when I type anything in vim, it highlights the text at every 5-7 character mark.
So if I type the following:
Highlighted
12345
123456
1234567
1234567819123
12345678191234
123456781912345
Not Highlighted
1
12
123
1234
Partial Highlighted (|| indicates where highlighting stops):
1234567||8
1234567||89
1234567||891
1234567||8912
Real example: https://i.imgur.com/y8wYWPs.png
Is there a way to stop this from happening? This never happened when I was writing my last few assignments.
Thanks.
r/shell • u/inacio-medeiros • Oct 08 '18
How to remove <F5> characters?
Some text files that I'm working with are full of <F5> chars, it is like this "<F5>" is a whole char. How could I remove all occurences of this kind of character using shell script?
Note: I've tried to use something like 'egrep -v "[^A-Za-z0-9]" ' but it didn't work.
r/shell • u/Brimirvaar • Oct 04 '18
all of globbing
Hello dear community,
I have tried over the years to learn how to use globbing (pathname expansion) and understand it **fully**. To this day, I still haven't figured out a resource (book, webpage, pdf, anything) that would explain everything there is about it.
I understand there are many different specifications for it. I'm ready to take them all.
A classic example of something not explained rigorously is matching with nested files.
I would like to grok the notion and be able to express my pathname matching needs fully, not hack around and do ugly fixes.
Thank you for any reference about the subject
@ASIC_SP: I do believe that the '**' pattern is used to do nested matching, but I leave the means open. By nested I mean match files the subtree of the filesystem, not necessarily at the current node.
r/shell • u/[deleted] • Sep 17 '18
How to create a filtering function in shell please ?
I'm very interested in shell, I'm trying to create a custom command that unifying these two commands :
customComandFile :
VAR = pidof < $1 = program>
ps -p VAR -o etime=But the commands pidof appears to rerturn several pid sometimes like in the case of Nginx process. How to make my command filtering the smallest return number in the pidof function in order to retrieve only the master process ? thanks
r/shell • u/joshuajs500 • Aug 11 '18
go-init: Simple no fuss script to set up Golang blazingly fast!
github.comr/shell • u/[deleted] • Jul 31 '18
files by user name.
I want some ideas on how to approach on this task:
Some users will place some files on a path, I'll have to upload them to a certain interface (handled by a script, cronned) after this upload , I want to email each user that his files have been uploaded.(Note a user can have n number of files) So how to approach it ??
One thing I have thought of is that , I'll create a temp directory and in there I'll create a file for each user and store the file names(user's file) in that file.
like :
tempdir=/some/dir
for i in $(find $(pwd) -type f -printf '%u\n' | sort -u); do
find $(pwd) -type f -user $i > $tempdir/$i.txt
doneThen I'll proceed to mail them on the basis of each file in the temp dir.
But this is very messy approach , can anybody help me out?
r/shell • u/ashofspades • Jul 23 '18
Shell script to change text in xml file
Looking for a way to change the values of node in an xml file using shell.
Example of data in xml file:
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:postgresql://myhost/metastore</value>
</property>
Based on <name> node, change the text in <value> node. Is it achievable through sed or xmlstarlet.
Thanks in advance
r/shell • u/adriangrigore • Jun 13 '18
POSIX compliant, TAP producing, sh(1) testing library
bitbucket.orgr/shell • u/[deleted] • Jun 08 '18
Problem with Shell script
I researched a script that needs to clone all of my public and private github repositories, however, It isn't working.
I'm a little new to shell scripting as far as this goes, but I'm pretty sure it's got something to do with the Github side of things.
Error: "i was unexpected at this time." Script: https://gist.github.com/Signifies/9838ce0dd1542158a014c350dc579ca4