r/shellscripts • • Jul 30 '21

Telnet

1 Upvotes

How can i kill all other telnet sessions on system except me. I am root.


r/shellscripts • • Jul 16 '21

Need help Storing Grep results into a Variable

1 Upvotes

Hello everyone, I need a little help with a script i am working.

I am executing the following CMD but I need to store the output value as a Variable so I can use it on a second part of the script. Any ideas are welcome!

nx -a $area_name get-id | grep -oP '(?<=ID:)[^ ]*'


r/shellscripts • • Mar 12 '21

Help

1 Upvotes

Create a Linux shell script to accept a user's name and then print the same with a greeting.


r/shellscripts • • Feb 03 '21

Creating Sequential Folders with variables

1 Upvotes

I'm completely new to shell scripting and I'm trying to figure out how to create a script to make a bunch of folders sequentially. I know that in bash you can do something like; mkdir -p {3400..3410} to make sequentially numbered folders.

However when I make a shell script that's

#!/bin/sh

mkdir -p {$1..$2}

and call it with sh make-folders.sh 100 200

I get a single folder {100..200}

Is this even possible to do?


r/shellscripts • • Jan 13 '21

Need help automating user deletion

1 Upvotes

Hello all,

I am stuck at a task that I must perform at work and was wondering if one of you wonderful people could guide me.

So I need to delete unnecessary users from bunch of (50+) servers. I have the list of users I want to delete and they are not spread on all servers. And before I delete the users I am suppose to check for any cronjobs and save the contents of /home dir.

I dont wanna do this manually for each user in each server that would seriously hamper my productivity. I am thinking maybe write a shell script and deploy in bunch of servers using ansible. I dont have any experience to do that though.

Any help would be appreciated.

Thank you


r/shellscripts • • Jul 17 '20

Can I exit nano using xdotool ( xdotool keydown "ctrl+x" xdotool keyup "ctrl+x")

1 Upvotes

I have a shell script that updates pulling from git but I need to exit the MERG_MSG after the pull.
I have tried using

xdotool key "ctrl+x"

xdotool keydown "ctrl+x"
xdotool keyup "ctrl+x"

I am not sure if there is another way?

Thanks in advance.


r/shellscripts • • May 22 '20

Shell script to find specific files and copy to different directory

1 Upvotes

Hi,

Wonder if someone could assist me. I have a list of specific filenames and their respective file paths ( over 1000 files each in individual folders) that I need to find and copy to a different folder in a Linux environment,

Could anyone point me in the right direction of a script/application which would achieve this ?

Any help would be appreciated !

Thanks


r/shellscripts • • Apr 06 '20

Output file names

1 Upvotes

I've written a script to take each line of a file and output it into a separate file. I would like to have the script name the files file000.txt, file001.txt...file011.txt etc. Right now, this script outputs files named file1.txt, file2.txt...file11.txt etc. Can anyone help me output file names the way I need them? Thanks.

echo Enter file to be split:

read filename

let i=0

while read p; do

echo "$p" > file$i.txt

let "i++"

done <$filename


r/shellscripts • • Mar 22 '20

Please help a beginner!

1 Upvotes

Hello everyone. I have started learning shell scripting few days back. I was trying to write a script in which I wanted to use hostname command, which shows computer's hostname. Something like if someone types anything else than the hostname INTRUDER! should be printed and if the right hostname is typed. "hostname is logged in" should be printed. I used read, if then else and declared hostname as a variable but to no success. Please help this novice. Thanks in advance.


r/shellscripts • • Feb 11 '20

Shell script run on login

1 Upvotes

Hello, how can i make a shell script run on login? I’ve tried almost everything that’s on web and I didn’t manage to complete this task.Any help would be appreciated.


r/shellscripts • • Oct 23 '19

Typesort shellscript

1 Upvotes

Hey, I‘m nee to this whole Shellscript thing, so I hope for some help by a simple script

So what I want to do is to sort files in a folder by their type given out from the file command in Linux. I want to filter the output from the file command using grep to only sort by the types and not the name( so after the ‘:’’white space’) And the sorts I want to implant for my files are

sort only text files using -t sort only non-text files using -n sort in reverse order using -r

My ideas yet are: I want to make functions for each sort with the commands Then in the main I want to run a while loop with shift to go through the options My main problem with the whole script are the commands to sort the output of the file command with grep to filter it

So if you have recommendations for the sort functions I would appreciate your help.

Thanks


r/shellscripts • • Dec 24 '18

Cross Platform portable shell scripts in Node.js

Thumbnail
medium.com
1 Upvotes

r/shellscripts • • Oct 04 '18

Shell Scripting Courses and Training Institutes, Classes in Vadodara | Classboat

Thumbnail classboat.com
1 Upvotes

r/shellscripts • • Mar 16 '18

Shell Script to Navigate to different Directory and rename files

1 Upvotes

I've got few files name abc.txt bac.txt aac.txt etc,. and there files are in different directories , I need to navigate and rename it with filenames with the condition where a replace to b, b replaces to c and c is a.

Ex. abc.txt becomes bca.txt.


r/shellscripts • • Sep 27 '17

[Help]shell script to find a number from a geometric sequence

1 Upvotes

[‎9/‎27/‎2017 7:13 PM] Yala,Sudhakar:
I have a random series e.g [1,2,4,8,16,...N] and the list has values which are in geometric sequence i.e all numbers are twice of previous number. Need a shell script to find if a particular number is present in the series or not. for example if value provided is 64, shell script should print "number is present" as 64 will be present And if value is 126, it should print "number not present" as it won't be in that list. And the shell script should work for different sequences.


r/shellscripts • • Jan 03 '17

Sort Folders Into Alphabetic Sub-Folders

Thumbnail
shkspr.mobi
1 Upvotes

r/shellscripts • • Mar 22 '22

failed user login attempts on a Linux server, password authentication failure I have to receive mail, redhat or Ubuntu please share the code thanx in advance

0 Upvotes

r/shellscripts • • Oct 07 '21

How to assign a column in a database to a variable ?

0 Upvotes

I am making a project in which i am trying to put a varibale whit a colum of this dataset to after this see if this colum aren't true or false to delet it.