Click here to Skip to main content
15,891,657 members
Everything / Programming Languages / Shell

Shell

shell

Great Reads

by V. Subhash
About odd but critical shell-programming details that get easily forgotten or ignored
by Mr. xieguigang 谢桂纲
How to build my own 3D graphics engine from ZERO step by step
by Kewin Rausch
Moving forward in the future networks evolution
by fd9750
Overview of required tools to cross compile/build/remote debug C/C++ projects on a Windows host ( 10 ) for a Raspberry PI 3B

Latest Articles

by V. Subhash
A simple fix for excessively bright video and low-volume audio
by hemanthk119
Steps to enable VPN client on an OpenWRT router using openvpn and mwan3
by Ben McNamara
Container classes much faster than STL.
by k5054
How to update a bash variable inside a loop when reading from command output

All Articles

Sort by Updated

Shell 

16 Jan 2024 by Richard MacCutchan
As already suggested to you you need to use ProcessBuilder (Java SE 18 & JDK 18)[^]. The documentation shows how to build a command and use this and associated classes to start it. And here is a tutorial with sample code:...
16 Jan 2024 by ManuelGNUBSD
Iam a beginer programmer java on Debian Linux 12 (Later may be on FreeBSD 14 too) and I would like to make an small application a Java Swing launcher to launch some java web servers like Jetty, Glassfish and Wildfly for webdevelopment and to run...
5 Nov 2023 by V. Subhash
A simple fix for excessively bright video and low-volume audio
14 Sep 2023 by rvjay supatan
Objective: I need to run this executable program on this path "\\172.168.0.46\Inhouse Module\Michael Panaligan\AllUnit\RunCom.exe" It's working on my local computer but not on IIS Server Side. I don't know why it's not working on IIS Server Side...
25 Aug 2023 by keithdr1965
wmic /node:172.168.0.46 process call create "full path to exe and parameters" You may need to do some additional research around authenticating to the target. Based on my (brief) testing, the result process is running at a system level, not a...
15 Aug 2023 by Richard Deeming
Quote: I'm expecting to launch the application on the client. Well, there's you problem. Code running on the server cannot launch an application on the client. It might appear to work when you debug your code locally. But that's only...
5 Aug 2023 by headshot9x
Hi, I have log files coming from other servers, the content in file something wrong and I want to rewrite content before move file. I'm not familiar with shell script in linux, but I tried research and learn around. So, I have idea about, but so...
17 Jul 2023 by Shreyansh Shukla 2021
I have the below condition where values are as below. ``` emp_name="Sid" emp_id=1234 emp_hobby="" emp_likes="swimming" emp_dislikes="" ...
17 Jul 2023 by Member 10601191
cat script #bash script emp_name="Sid" emp_id=1234 emp_hobby="" emp_likes="swimming" emp_dislikes="" emp_summary="" summary="" # # if the names are not known ..._ # then use something like # for var in $(compgen -v|grep ^emp_) for...
16 Jul 2023 by hemanthk119
Steps to enable VPN client on an OpenWRT router using openvpn and mwan3
7 May 2023 by as7951
Experts, Need your support for this awk script. we have only one input file, all these column 1 and column 2 are in same file and have to do lookup for values in one file(column1 and column2) but output we need in another file Need to grep row whose string contains 9K in column 1 and then grep...
7 May 2023 by Member 10601191
/^9K/ { kees[$0]; next; } { for ( key in kees ) { # # is it part of the key ... # if ( match( key, $1) ) { if(...
22 Apr 2023 by Ben McNamara
Container classes much faster than STL.
8 Mar 2023 by k5054
How to update a bash variable inside a loop when reading from command output
6 Mar 2023 by V. Subhash
This final part of the article series covers some other important behaviour of bash, particularly that relating to text expansions and substitutions.
5 Mar 2023 by V. Subhash
About odd but critical shell-programming details that get easily forgotten or ignored
8 Feb 2023 by Richard MacCutchan
I just tried this on my Linux system, and the tests for "One year" and "Two year" fail, because the read command splits them into two fields. I have tried putting them in quotes, but it still splits them at the space character. I guess you have...
8 Feb 2023 by Neha Thachil
I'm trying to create 3 csv files based on the contract type. The Month_to_month.csv has gotten created but why aren't year 1 and 2 working? Please help! What I have tried: %%! contract_month=0 contract_1year=0 contract_2year=0 for line in...
8 Feb 2023 by Andre Oosthuizen
You are using shell to reference the path to the file and the name of the file. The error states that either the path or the file name OR both is incorrect. Looks like you are using Python, see Find path to the given file using Python[^] with 3...
21 Dec 2022 by J de Villiers
So I changed the approach... instead of the conventional looping systems I created an artificial one. Started by outputting "lsblk -o NAME,SIZE,UUID,MOUNTPOINT | grep ${activeDevice}" before and after to a separate files, using the "diff" command...
21 Dec 2022 by J de Villiers
#!/bin/bash Hey folks So I am sitting with a conundrum... am attempting to call a function from with a loop that resides with another loop. Problem being that the two loops do not wait for input... they simply continue to execute and with that...
17 Nov 2022 by h_wiedey
This tip shows how md5 and locate can be used to find duplicate files.
10 Nov 2022 by ANNA Genone
I have installed (pkg install audio/pocketsphinx) and is trying out the testing command ( pocketsphinx_continuous -inmic yes ), but am met with the following screen: INFO: continuous.c(371): pocketsphinx_continuous COMPILED ON: Nov 5 2022, AT:...
13 Oct 2022 by PArI Parimala
Hello, I am new to shell scripting. This is the sample date and time stored in UNIX system. here date part is common I will use shell script and cut this date part. 20221010042234.671 - 20221010042234.491 20221010132747.826 - 20221010132747.712...
13 Oct 2022 by k5054
Depending on what tools you have available, you have a few options. Lets assume that you can put your two operands in arg1 and arg2 respectively then Perl: perl -e "print $arg1 - $arg2" bc: echo "scale=3; echo $arg1 - $arg2" | bc awk: echo...
26 Jul 2022 by Goutham GSK
Hello Everyone, I am trying to read a file which contains numbers(Floats and integers) line by line, I am able to read the line correctly and it works fine, but when I try to compare it with a different number I am failing at that point ...
26 Jul 2022 by k5054
You can use normal comparison operators inside a bash [[ ]] expresion. Try if [[ $line > 30 ]]; then ... fi
12 May 2022 by Bryan Woodruff
I am trying to access a variable outside of function but I cant get it to work properly it might have something to do with the subshell but I am not too sure. I'm very new to shell at the moment I am trying to access the elapsed variable from...
12 May 2022 by Richard MacCutchan
Here is a simple recursive function to print the Fibonacci sequence up to 100: fibo() { echo -n $1 if [ $2 -lt 100 ]; then echo -n ", " let tot=$1+$2 fibo $2 $tot fi echo "" } fibo 0 1 It should be...
12 May 2022 by k5054
I'm assuming your using bash. First off, I assume that the line elapsed=$(( end-time - start_time )) is just a typo and that end-time should be end_time But looking at that statement, it's all just wrong. If you are using bash, then you could...
21 Apr 2022 by Matt Pogue
Scripting is a crucial skill for any admin to learn. This post walks through the process to develop a batch file download script in Python, demonstrating how to use the interactive Python shell to troubleshoot while writing code.
8 Apr 2022 by Randor
Hi, You can install the Windows SDK[^] and the MakeAppx and SignTool utilities are included. The steps you need to take are here: Grant identity to non-packaged desktop apps[^] It's not as difficult as it looks, you can use this old code...
8 Apr 2022 by Gary R. Wheeler
The context menu in the Windows 11 File Explorer has moved all shell extensions to the "shift-F10" submenu. The available documentation seems to state that Win32 apps must be installed using UWP methods to integrate with the Win11 Explorer. This...
5 Apr 2022 by ubutu2334
Enter a list of students names from the keyboard and save the list that was sorted into the file students. Check the contents of the file students What I have tried: cat >> students -> What about the arrangement part? ls students Thanks
5 Apr 2022 by Richard MacCutchan
sort(1) - Linux manual page[^]
17 Feb 2022 by Peter_in_2780
Run it through something like this: svn info | awk 'BEGIN {FS="/"} /^URL:/ {print $6 "/" $7 "/" $8}' [edit] fixed typo [/edit]
16 Feb 2022 by Member 14030165
So I have a svn repo URL like this-- svn info Path: . URL: svn://xyz-repo/svn/ccsmp/branches/features/cre40_jenkins Repository Root: svn://xyz-repo/svn/ccsmp Repository UUID: 5de8f2f4-0d3b-0410-8f2c-d418a2640d16 Revision: 23430 I want to grab...
13 Feb 2022 by steveb
This is impossible. When machine first powers up, there are no Python interpretes on a BIOS level. There fore this cannot be written in Python. Maybe only after boot code was executed. But why would anyone want to write an OS in a slow...
13 Feb 2022 by آرین عباسی 67
I want to rewrite the Linux kernel written in C and Assembly and Ruby and Python programming languages ​​and integrate it completely with Python. I need some help because I only know Python. I'm looking for a C, Assembly, Ruby, Shell programming...
12 Feb 2022 by Richard MacCutchan
You probably need to start by looking at the existing source code at GitHub - torvalds/linux: Linux kernel source tree[^].
11 Feb 2022 by Patrice T
Quote: I want to rewrite the Linux kernel Bad idea. If there is not millions of Linux written in everyone's favorite language, it is because it is huge and hard, and not every programming language is usable to build an OS. An OS talks to bare...
11 Feb 2022 by OriginalGriff
Forget it. Python needs an OS to work: it's an interpreted scripting language which needs the interpreter (which provides the framework for your app to run) to be executing before your app does. And that needs the OS beneath it to provide...
11 Feb 2022 by DoingWork
I want to start 2 applications with one shortcut. One application is GUI based while other is shell based (Terminal=true in .desktop file). What I have tried: For this goal, I created a file name **Starter** having following script in this...
29 Jan 2022 by Sakshi15
I have written a C function which write 10 bytes at end of file. I want to test whether it works in shell script using command like diff,cat etc. What I have tried: I tried commands like diff but I am not getting how to use the command in shell...
29 Jan 2022 by OriginalGriff
It's going to depend on your OS - the Linux diff is different from the WIndows version, but since you mention cat, I assume you are using linux for some reason. This may help: Shell script using Diff[^]
11 Jan 2022 by mc96
I have a bash shell script that performs a cURL command, and gets the raw output of an array inside the json array. I can also successfully echo the number of elements in the array Why can I not assign the amount of elements inside the array to...
11 Jan 2022 by mc96
SOLVED! realoutput=$(echo $output | jq '. | length') echo "OK|janusSessions=$realoutput" Produces: OK|janusSessions=2
11 Jan 2022 by Richard MacCutchan
I do not think you need the extra pipe symbol in: echo $output | jq '. | length' ^ Try echo $output | jq '.length'
6 Jan 2022 by mc96
So far my bash script is as follows: #!/bin/sh sessionnumber=0 curl --data '{"command":"listsessions","transaction":"123","adminsecret":"secret"}' -H "Content-Type: application/json" http://127.0.0.1:8088/admin This successfully returns the...
6 Jan 2022 by k5054
Parsing JSON using standard tools (grep, awk, sed, etc), is probably more difficult than you imagine. You really need a JSON parser. This is discussed here: bash - Parsing JSON with Unix tools - Stack Overflow[^] Looking at the home page for ...
16 Dec 2021 by AlexeyAB
Atomic operations and C++11 memory barriers and assembler instructions generated on x86_64 CPUs
16 Oct 2021 by Peter_in_2780
cert_expiration_epoch=$(date +%s -d "$cert_expiration") You really should start using the basic tools available. date --help man date man bash Also as someone else already told you, it's much better to use $(command) rather than `command`
16 Oct 2021 by wifinut
I need to compare today's date in Epoch time to another Epoch date stored in a variable. I can store today's epoch in a variable with no problem. I run into trouble when I try to store a derived $cert_experation_epoch. This is most likely a...
1 Sep 2021 by Member 15343067
Hi All, I'd like to code an outlook VBA macro that allows me to save .tif mail attachments in .pdf Since no such Outlook option exists, I first save the .tif as it is and then I am launching "Windows Photo Viewer" to open it, then I choose the...
1 Sep 2021 by CHill60
AFAIK there is no way to capture that button click as you are shelling the application, not interacting via an API.Quote: Last thing, If someone knows an alternative way to get to the same results in Outlook directly, this will be equally highly...
18 Jul 2021 by wifinut
I'm trying to add a speed test to my BASH script. I know you can install speedtest-cli on the host, but this is not an option. I'm looking for options perhaps using the CURL command. What I have tried: I tried using a CURL command to obtain the...
18 Jul 2021 by Daniel Pfeffer
Working backwards from the numbers that you give, we get 1 block = 100Mb / 22355 = 4473 bits. This looks close to a 4 Kb (i.e. 512 byte) block size. Adding various header and framing bits make the correspondence even better. I expect that you...
21 Jun 2021 by V. Subhash
Cut, copy, convert, mix, rotate, flip, resize, crop, combine, compose, blur, sharpen, smoothen, side-by-side split, PIP inset, fade in/out using FFmpeg Filters
9 Jun 2021 by wifinut
I’m trying to use osascript to produce a simple UI menu, but instead of the default “OK”, and “Cancel” I would like to change the behavior to the following: “Cancel” changed to “Exit” “OK” changed to “Run” Have the “Run” button execute a BASH...
27 May 2021 by Oscar-Tark
In this article, we will be looking at a more advanced version of a buffer overflow attack.
26 May 2021 by Patrick P. Frey
In this article we see how a very primitive compiler is written in Lua using Mewa and how to compile and run a simple demo program in the shell.
25 May 2021 by Jarek Szczegielniak
In this article, we publish our NLP API service to Azure using Azure Container Instances.
21 May 2021 by Jarek Szczegielniak
In this article we use Visual Studio Code to edit and debug our increasingly complex code running inside a Docker container.
20 May 2021 by Rob Rob 2021
Good day, I want to mix all the words between them, but my method with `@content.Split ` and `replace` seems doesn't change too many words between them. Can anyone help me? What I have tried: $fileName = "C:\Folder1\file.txt" $newfilename =...
20 May 2021 by Rob Rob 2021
((Get-Content -Path C:\Folder1\file.txt -Raw ) -split "\s+" | Sort-Object {Get-Random} ) -join ' ' | Out-File -FilePath C:\Folder1\NewFile.txt
18 May 2021 by Jarek Szczegielniak
In this article we run inference on sample images with TensorFlow using a containerized Object Detection API environment.
27 Apr 2021 by Jarek Szczegielniak
In this article, we’ll create a container to run a CPU inference on the trained model.
20 Apr 2021 by Padala Vamsi ujpNQUXGRi
I found solution we can simply use Process Substitution. cat
20 Apr 2021 by Padala Vamsi ujpNQUXGRi
I made a c program which takes two standard inputs automatically and one manually. #include int main() { int i, j; scanf("%d %d", &i, &j); printf("Automatically entered %d %d\n", i, j); int k; ...
20 Apr 2021 by k5054
When you use a Here Document, the shell effectively does echo -e "1\n2\n" > /tmp/tempname ./test
16 Dec 2020 by vigneshjayaraman
I have set the winlogon shell registry to my executable application. I have no issues running my application. Buti have to set the background for kiosk mode so that if multi monitors connected i can display the selected image to wallpaper for all...
26 Sep 2020 by Member 13702159
I have the code like below. It is from circleCi = ci/cd tool , this use shell script also. The problem: When I pass test_branch or master directly like this --data '{ "branch": "master" }' It works fine. But I need to pass a parameter. When I run...
2 Jun 2020 by Richard MacCutchan
You just need to capture the depth value and reduce it by 1 each time you call check_dir. Something like: function check_dir { depth = $($2 - 1) // reduce the depth count by 1 echo Checking dir : $1 for f in `ls $1` do ...
2 Jun 2020 by Member 14825085
I am writing a script which searching the given path(first parameter) and prints number of dirs, files etc.Update table is just a function which sorts my datas. My problem is how can i insert here the depth of searching. The depth will be the...
25 May 2020 by Jonathan Nethercott
Automated Raspberry Pi Setup for .NET Core development and remote debugging using Visual Studio Code
20 Apr 2020 by phil.o
Here are a few examples: Bash Infinite Loop Examples - nixCraft[^]
30 Jan 2020 by fd9750
Overview of required tools to cross compile/build/remote debug C/C++ projects on a Windows host ( 10 ) for a Raspberry PI 3B
13 Nov 2019 by Marijan Nikic
One-file shell-integrated easy solution for automatic recognition of movies and TV shows
1 Aug 2019 by Michael Haephrati
A tiny Command Line Interface wrapped with a Graphic User Interface
30 Jul 2019 by Don Hoang
This post describes implementing ASP.NET Gridview using Bootstrap 4.
31 May 2019 by Rick Lunglhofer
Details the Implementation and use of a C Language Interpreter with a browser Interface running on an ESP32
24 Apr 2019 by QxOrm
QxOrm C++ library: Persistence (based on QtSql Qt library) - Serialization (based on boost::serialization library) - Reflection (introspection)
11 Apr 2019 by WOLF 2018
I found a way of doing it by converting the bytes to hex and removing the “a0” at from the bytes and then convert it back to a string data = r.recv(1024) data = codecs.encode(data, ‘hex’) data = str(data).replace(‘a0’, ‘’) return codecs.decode(data, ‘hex’)
11 Apr 2019 by WOLF 2018
i am trying to make my own root shell for my server so that i can work on the in side of it, but ever time i try and check if the input == "exit" it just don't check it and continues. sorry is this is spelled wrong, i am not english. i just can't see what i am doing wrong. plus i am trying to...
28 Mar 2019 by #realJSOP
Try this (no guarantees, just a stab in the dark): if (data.lower() == "exit"): or maybe if (data.lower().startswith("exit")):
16 Feb 2019 by faizanza
Hi, im working on a personal project that opens other programs and currently I am using a text file where I have to manually enter the path to the exe file like this C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe I wanted to know is there a way to get a list of all the...
16 Feb 2019 by Richard MacCutchan
You can only get what the installer has put in the registry. But not all programs will necessarily have a proper registry entry. You can also look in the Start Menu folder in the APPDATA trees for all users.
18 Jan 2019 by Member 14121946
@ECHO OFF if not "%1"=="STDOUT_TO_FILE" %0 STDOUT_TO_FILE %* >>local_repo_log.txt 2>&1 shift /1 REM Script to migrate tfs to git repo. REM Reads tfs repo url from control.txt and pushes to git @echo Migration Started: %date% %time% REM read from control file FOR /F "usebackq tokens=1-10...
17 Jan 2019 by Ramon F. Mendes
Create HTML/CSS/script based cross-platform desktop apps in C# with Sciter engine!
9 Nov 2018 by YasIkeda
Tutorial about how to add authentication functionalities to your existing ASP.NET Core project using Microsoft.AspNetCore.Identity.UI package
9 Nov 2018 by Сергей Челноков
10 Oct 2018 by abdul subhan mohammed
Hi Guys, I am attempting to write the following code in .net 3.5. The code is trying to loop through verbs (i.e. Pin to Start, Open, Create Shortcut, etc) This code does this in 4.5. What I have tried: string path = Path.GetDirectoryName(filePath); string fileName =...
10 Sep 2018 by Kewin Rausch
Moving forward in the future networks evolution
5 Sep 2018 by BillW33
There is a good example of how to loop through all the keys for a registry here: https://stackoverflow.com/questions/1458653/iterate-through-registry-entries Read about the Registry Key Class here: https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.registrykey?view=netframework-4.7.2 ...
5 Sep 2018 by Thaana Paana
I want to return the windows right click items that is in HKEY_CLASSES_ROOT in order. By order like when you click a folder or a certain extension you get different menus and they are in separate places in HKEY_CLASSES_ROOT, how does windows know to return them in order on right click when they...
5 Sep 2018 by Richard MacCutchan
If you do not know anything about this subject then I would suggest starting with a simpler project. You can find lots of useful tutorials in the https://www.codeproject.com/KB/shell/[^] section, or by using Google.
25 Aug 2018 by Kewin Rausch
Introduction to protocols to manage Key Exchange in secure channels communication
6 Aug 2018 by Jochen Arndt
If you are aware of the write() function you should be also aware of the read() function. To read from the keyboard pass zero as first parameter (file descriptor stdin). Use a while loop to read single characters and store them in an array until a new line ('\n') occurs (user pressed the ENTER...