Click here to Skip to main content
16,022,737 members
Everything / Shellscript

Shellscript

shellscript

Great Reads

by dkoksal
Discern what wireless chipset your device is using with dmesg.
by dkoksal
Take some of the headache out of Android porting with a stable, consistent build environment.
by Gautham Prabhu K
Perform custom disk clean up when hard disk free space goes low
by Grasshopper.iics
Workaround for Sending Bluetooth command from Android Phone to Javascript based programs in Intel Edison

Latest Articles

by Grasshopper.iics
Workaround for Sending Bluetooth command from Android Phone to Javascript based programs in Intel Edison
by dkoksal
Discern what wireless chipset your device is using with dmesg.
by dkoksal
Take some of the headache out of Android porting with a stable, consistent build environment.
by Gautham Prabhu K
Perform custom disk clean up when hard disk free space goes low

All Articles

Sort by Score

Shellscript 

19 Jan 2014 by Vedat Ozan Oner
awk is a very powerful tool. I advice you to use it.ls *.bmp | awk -F"_" '{ print $0" "$1"_fp_"$2".pk" }' | while read a bdo mv $a $bdone
2 Jan 2015 by Doug Vanderweide
What you are trying to do is extremely dangerous from a security standpoint. Just keep that in mind.That said, you have two options:1. Change the permissions of your website's PHP user to be able to execute shell commands. This is a terrible idea and you shouldn't do it because it is...
16 Dec 2015 by Jochen Arndt
You can use the Substring Extraction (see http://tldp.org/LDP/abs/html/string-manipulation.html[^]):stringInput=12345678str1=${stringInput:0:2} # 12str2=${stringInput:2:2} # 34str3=${stringInput:4:2} # 56str4=${stringInput:6:2} # 78If the input string has variable length use a loop...
17 Mar 2021 by CPallini
Try fin = open('input.txt', 'r') fout = open('output.txt', 'w') linesin = fin.read().splitlines() seqnum = 1 previous = None for lin in linesin: if previous != None: if lin == 'APPLE': previous += str(seqnum) seqnum = seqnum +...
6 Oct 2014 by dkoksal
Discern what wireless chipset your device is using with dmesg.
11 Dec 2014 by Kornfeld Eliyahu Peter
In Python the indentation of your code is critical to the compiler to understand you...In your case def __init__ not indented so this is no part of class - the default creator takes no parameter...The code should look like this:class Employee: """ Employee has name, one staff number,...
23 Jun 2015 by Richard MacCutchan
It is some time since I wrote any bash scripts but I think you may need something like:#!/bin/bash# find all .gz files of 10k since yesterday, and count themcd COUNT = `find . -name "*.gz" -size -10k -mtime -1 -print | wc -l`if [ $COUNT -eq 0...
1 Oct 2015 by CPallini
Quote:system("/home/sandy/sftp...
1 Dec 2015 by CPallini
Possibly you have to use a tool. See for instance this Stack Overflow question: "How to measure actual memory usage of an application or process?"[^].
16 Dec 2015 by Member 12211106
I want to split "12345678" into first variable or arr[0]=12second variable or arr[1]=34third variable or arr[2]=56fourth variable or arr[3]=78How can I do this in UNIX shell scripting without any delimiter of ;,,: etc...
25 Apr 2016 by Richard MacCutchan
s1= more /home/mohsin/Desktop/system_usage_bash_file | grep TIME | awk 'BEGIN {FS=","} {print $3}'As far as I remember shell scripts, you need to put the command in back quotes thus:s1= `more /home/mohsin/Desktop/system_usage_bash_file | grep TIME | awk 'BEGIN {FS=","} {print...
6 Sep 2016 by Dave Kreskowiak
There is nothing in the command line that will cause this.The problem has a number of causes. First first being a network connection between the machine running this batch file and the source and destination file locations.Next, the files could be locked and in use when XCOPY gets to the...
9 Oct 2016 by OriginalGriff
No. We do not get involved in bypassing legitimate security features in any way, shape, or form.This is a professional site for professional developers, not a hack site. Talk to the manufacturers of your tablet / phone.
9 Nov 2017 by Jochen Arndt
You are trying to do it too complicated. Just assign the string as it is (but escape double quotes): VHOST=" DocumentRoot \"/var/www/html/${PROJECTFOLDER}/public\" AllowOverride All Require all...
21 Feb 2019 by Peter_in_2780
Delete the &. With it there, each python command is launched as a separate background process, so they will all run in a terrible jumble. Without the &, they will run sequentially as you expect.
24 Mar 2021 by k5054
Problem one seems to be a mix of UTF-8 and ASCII quotation marks (") in your code -- assuming you did a cut&paste from your source. Next, your logic is slightly off. You break the while loop and report no matches on the first non-match. One...
22 Jun 2021 by Richard MacCutchan
This is your fourth question on this exact problem and you have been given all the available suggestions. It is now time to start putting all the information together. And as you should be aware, system commands do not always have a direct C/C++...
26 Jul 2022 by k5054
You can use normal comparison operators inside a bash [[ ]] expresion. Try if [[ $line > 30 ]]; then ... fi
20 Nov 2013 by SNI
Hi,I want to pass about 8-10 parameters to shell script from javascript or Ajax. I am using XMLHttpRequest to call shell script but I want to pass parameters to it. Pls let me know how to achieve this.RegdsSNI
4 Dec 2013 by Arun Kumar K S
I created one init.d script to run my C++ daemon using /etc/init.d/skelton script from ubuntu. and installed the new script using "update-rc.d myservice defaults 99" command its working perfectly. Now I want to create two more shell scrits one needs to run at the beginning of the boot as...
4 Dec 2013 by Richard MacCutchan
See http://www.ghacks.net/2009/04/04/get-to-know-linux-the-etcinitd-directory/[^].
17 Dec 2013 by SanketAB
Hi All,I have one difficulty here with my Shell script. I want to send four text files and one csv file as attachment using mail or mailx and uuencode utility on Solaris server.It is Sun Microsystems SunOS 5.10Here is my code( uuencode "file1.txt" "file1.txt" ; "file2.txt"...
17 Dec 2013 by Richard MacCutchan
Try something like:cat file1.txt file2.txt | uuencode | mailx -s "Subject" someone@abc.com
18 Jan 2014 by Sanjeev236
Dear All,I am good in excel so till now doing with excel but now data is too hugh,more than 8 crore records. So its difucult to downlaod gb's of data of rename the files.Need to rename few files as Source filename to destination filename...
26 Jan 2014 by SanketAB
Hey i found the workaround on this. Following is what now working for me( cat mailBody.txt; uuencode "abc.txt" "abc.txt"; uuencode "xyz.txt" "xyz.txt"; uuencode abc.csv abc.csv ) | mailx -s "attach test" someone@abc.com
10 Feb 2014 by Vedat Ozan Oner
assuming that you have ?(question mark) at the end of file:$ ls -1 *.*"?" | sed 's/.$//' | while read a do mv $a"?" $a done
10 Feb 2014 by CPallini
I don't know what it as to do with recursion. You may change file names this way:rename 's/\.bmp\?/\.bmp/' *(see How to: Rename multiple files with "rename"[^]).
13 Feb 2014 by Richard MacCutchan
See https://www.google.com/search?q=read+oracle+control+file[^].
17 Feb 2014 by Sergey Alexandrovich Kryukov
Used to work with Windows or even DOS, did you? :-)If this is your current directory, may be tar -cvzf ./mytesting201402070230.tar.gz ./mytesting201402070? Can you see the difference?—SA
5 Mar 2014 by Snehasish_Nandy
Referhow-to-clear-the-contents-of-a-file-from-the-command-line[^]
6 Mar 2014 by sharath kumar maddi
i found -fs for fullscreen of window but i want some shell code or arguement for window option 'always on top'.example for fullscreen is as below eog -fs '/home/Desktop/a.jpg'here eog is command for imageviewer application and -fs for fullscreen
11 May 2014 by user_code
hello,I have to write a unix script and I am really not familiar with it and need help.I have a root directory, inside it I have a lot of other directories.Each directory contains txt files.I have to go through all the directories and all the files.If a file contains the phrase...
11 May 2014 by CPallini
Your task is fairly articulated. Since you are not an expert on shell scripting I suggest you the divide, Google et impera approach: for instance, you could start searching for how to perform a recursive find in shell script[^].
20 May 2014 by txernobill
Hello, everybodyFirst of all, I'd like to say thank you to all of you for the forum (admins, users...), it's a really valuable resource for a lot a people, including me.I don't know if this is the right place where to ask this, my question is about my homework. If it's not, please, could an...
20 Aug 2014 by DilipSutariya
How can i pass all argument in $1 in shell script. I mean i don't want to use other $2,$3..$9 without that how can i pass all the argument in only $1. if it's possible than someone tell me how to achieve that.
12 Sep 2014 by nikuuul
I am searching for one file, say "file1.txt", and output of the find command is like below./home/nicool/Desktop/file1.txt/home/nicool/Desktop/dir1/file1.txt/home/nicool/Desktop/dir1/dir2/file1.txtIn above cases I want only common parent directory, which is "/home/nicool/Desktop" in above...
12 Sep 2014 by DaveAuld
I think this answers your question.http://stackoverflow.com/questions/12340846/bash-shell-script-to-find-the-closest-parent-directory-of-several-files[^]
18 Oct 2014 by cxxxxf
There is a sentence "#!/bin/sh - The bare option - says that there are no more shell options; this is a security feature to prevent certain kinds of spoofing attack" in book "Classic Shell Scripting".How does "-" work ? Please show me an example.Thanks for your attention.
5 Nov 2014 by JennyChua
Hi People,I want to change the content of the data using shell script.The script run and will change all the 530, I just want to change only 530, not...
5 Nov 2014 by Mehdi Gholam
Try searching for : '|530|'
10 Nov 2014 by Member 10440553
How do I sed to retrieve URLs within single quotes?Currently, it can only retrieve URLs which starts with HTTP/HTTPS.urls=$(sed -ne 's/.*\(http[^"]*\).*/\1/p' 's/.*\(https[^"]*\).*/\1/p' /url/to/path)
11 Dec 2014 by Member 11303406
I'm trying to create a python code for employees using the following code but it is coming up with an error "Object () takes no parameters) My objective is to create a program to keep track of employees in an organisation, by allowing the user to add and remove employees from a simple database...
5 Jan 2015 by Sergey Alexandrovich Kryukov
This is the code dump, not a question. Also, please don't re-post; this is considered as abuse. Please see: http://technet.microsoft.com/en-us/library/ms189863%28v=sql.105%29.aspx[^], remove '' marks. —SA
7 Jan 2015 by Vidhya Raju
I have installed .exe file using wine in my linux machine. Using shell_exec I could launch the exe file via command prompt using php. When I try to run php program from the browser am getting a blank page. How to launch the executables from the browser using php?php code:
22 Jun 2015 by Shaik Izaz
am using the below script to retrieve the NAME and PATH of the VM's and in the PATH am getting the full length path which i dont want it, i just need the path which is displaying after the Resources/here is my code:function Get-Path{ param($Object) $path = $object.Name ...
22 Jun 2015 by Shaik Izaz
Just Replace this Get-VM | Select Name, @{N="Path";E={(Get-Path -Object $_) -replace "^.*?Resources"}}
1 Oct 2015 by Member 11900955
I have a shell script it gets the files from another server int main() { char y[18]; // copying the value into y strcpy(y,"123456789.111"); // calling the shell script system("/home/sandy/sftp2.sh y"); return 0; } //end of main ...
2 Nov 2015 by Member 10308543
Hey guys,I am working on an Illustrator extension project which uses HTML5 for UI and JavaScript for implementing functionalities.Apart from HTML5 I am also using JQuery and AngularJS.Illustrator SDK has an special feature where you can execute a process using it.I need to pack a PDF...
19 Nov 2015 by krishna kishore58
Assume a file with below contents$cat file1Line1Line2Something!Line3Now I wanted to search keyword 'Line' and delete only the second matching line i.e., 'Line2'I am aware to delete all the matching lines as below.$sed -i '/Line/d' file1Please help me!!
30 Nov 2015 by krishna kishore58
Hello everybody,This may be the known question but before asking this I had searched a lot but did not find the precise answer.1.) How to find out the Heap, Stack and Swap memory usage of current running process in Linux box?2.) How to find out total and dynamic Heap and Stack...
20 Dec 2015 by Member 12018498
Can someone suggest me a tool which can test the POSIX complaint for a shell script.I searched in net, but couldn't find much apart from shell check.Please suggest me some more tools which help me in checking whether the shell script written follows the standards or not.Thank you in...
20 Dec 2015 by CPallini
See here for useful info: "How can I test for POSIX compliance for shell scripts?"[^].
16 May 2016 by Member 12485314
i want to overwrite value of variable s1 from "abc" to ---> [more /home/mohsin/Desktop/system_usage_bash_file | grep TIME | awk 'BEGIN {FS=","} {print $3}']but when i echo i get "abc" on both echos,means it is not overwrittenWhat I have tried:#!/bin/bashs1="abc"s2="USED"echo...
6 Sep 2016 by Shafikul
Hi Experts,I am trying to solve this problem almost two days. I am working on legacy .bat file which is running by windows scheduler at windows server 2008. But XCOPY copies 3 files which are very light but most of the time it doesn't copy the largest file. Last week it successfully copied...
5 Aug 2017 by sunil busam
Please help me how to write this code in shell scripting. What I have tried: Write a shell script to replace the lines containing a word “dd” with “ee” if it appears between the 5th and 7th position
24 Aug 2017 by KarstenK
Sounds like you need to learn some basics for your job. At first you need to read the file. How it can be done is explained in Input/output with files tutorial. After that you must split the string in parts as discussed in this answer of stackoverflow. I like the last sample code most. Than...
9 Nov 2017 by p1Ggy
Hi, I am looking for someone that can assist me with my .sh script. Please see script below: The commented section is where help is required when un-commented it sets anything below it as a "string" If any other issues are noticed in main script dump please do let me know :) ISSUE # setup...
5 Apr 2018 by Jochen Arndt
You can use a for loop to split the string at white spaces and ignore the "-------" matches: #!/bin/bash data="rep ------- zip ------- mnt ------- mnt ------- 952230" declare -a arr count=0 for i in $data; do if [ "$i" != "-------" ]; then arr[count]=$i count=$count+1 ...
6 Apr 2018 by Awadhesh Maurya
I want to download text file which is in remote server. If I use wget or curl -O to download sometimes it put html code inside downloaded text file. For example if text file name is text.txt which contain a line "hello world" by using- wget wget http://url/text.txt or curl -O...
6 Apr 2018 by Jochen Arndt
wget and curl retrieve and store files as they are. If you got unexpected data they are delivered in that format by the server. For testing purposes you can use the wget option --save-headers to check the Content-Type send by the server.
5 Apr 2018 by Member 13763555
when i'm trying to access data from XML file by using following cmd its giving data from all matching tag What I have tried: $ path="$(echo "cat /config/SourceFolder/FileSetFolder/Path/text()" | xmllint --nocdata --shell real.xml | sed '1d;$d')" output= rep ------- zip ------- mnt ------- mnt...
21 Oct 2018 by Richard MacCutchan
Go to Control Panel -> Update & Security -> Windows Update, and you can do it from there.
21 Feb 2019 by Member 13671328
Dear Expert guru I need your help. I have a command which I am running in terminal colsole. I want to make it run for all the files in the folder one by one and save the output as txt file. At the moment, I can only run it one by one manually for single file and get the output in colsole. ...
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...
20 Jan 2021 by Christian Graus
here[^] SELECT id, firstName AS "info.name", lastName AS "info.surname", age, dateOfBirth AS dob FROM People FOR JSON PATH; will select JSON
24 Mar 2021 by wifinut
I'm trying to scan a text file for values that match some values that I obtain earlier. For clarity I'm statically assigning them here. The input file is a CSV but doesn't contain any commas. I'm open to using a plain text file if that helps. ...
2 Apr 2021 by OriginalGriff
We could. But ... while we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be...
2 Apr 2021 by wifinut
I'm looking for a method to obtain my provisioned ISP bandwidth via shell script. To be clear, I'm not looking to do a speed test. My goal is the following: 1. Get my provisioned bandwidth (up/down) 2. Run a test to obtain the percentage of...
2 Apr 2021 by Dave Kreskowiak
The only way to get your bandwidth is a speed test. There is no information stored on your machine or any standard method on the internet to get your provisioned bandwidth.
2 Apr 2021 by Richard MacCutchan
If you type "man bash" at a terminal window prompt, you will find all the information you need.
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 ...
17 Jan 2023 by M Imran Ansari
The command to clear the terminal screen in a Cisco router using Putty is the "terminal length 0" command. You can enter this command by logging into the Cisco router and typing the command in the command-line interface (CLI) and press enter: ...
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(...
11 May 2023 by Rahul VB
Hello All, I am facing an unusual problem, i am trying to pass arguments to a build script through Jenkins command line, however i am not able to do so. When i capture and print the arguments it prints empty. Brief code is: argument=$1 echo...
17 Jan 2023 by balajidileepkumar
Not able to clear the putty terminal when ssh router What I have tried: clear cls ctrl+I ctrl+L "nothing above worked"
24 Sep 2014 by dkoksal
Take some of the headache out of Android porting with a stable, consistent build environment.
1 Aug 2014 by Gautham Prabhu K
Perform custom disk clean up when hard disk free space goes low
5 Oct 2017 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
20 Aug 2015 by Grasshopper.iics
Workaround for Sending Bluetooth command from Android Phone to Javascript based programs in Intel Edison
24 Aug 2017 by Jochen Arndt
For example by Reading the text file line by line Converting each line to a 64-bit integer and store that in an array Writing 8 values from the array to a text file separating them with a comma Depending on the language this might require to determine the array size in advance by...
23 Jun 2015 by Aiden.JP
I'm trying to make this bash script dispatch and email when it detects that a certain type of file (files ending in ".gz"), which was last modified 24 hours ago, is below a certain size in a directory, I currently have it running on my entire computer. (I have it set to 10 kilobytes).It just...
5 Aug 2017 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
24 Dec 2015 by Member 12227276
Hello Techie,this is my first question i am asking on code project. i am trying to parse xml file and Save the output in text tab delimited format in a specific location using either perl or shellscripting whichever is faster. i did this with sql and SSIS but it tooks more than 18 hours to...
25 Aug 2017 by Member 13376675
this txt file contains hex values i want to change this into dec and divided into li l2 t1 t2 v1 v2 p h these are hex values 4f337d5000000001 4f337d5000000001 0082004600010000 0082004600010000 334f464600010000 334f464600010000 4f33464601000100 4f33464601000100 334f464600010000 334f464600010000...
9 Jun 2015 by Member 11752915
I have written one shell script (Health_app.sh) which checks the health of the application..and for that it takes the name of the processes form App_Details file and checks for pid (whether it is running or not) and if it is not running and grep for that process in logs (field 3) and send email...
5 Aug 2017 by Patrice T
We do not do your HomeWork. HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them. Any failure of you will...
20 Jan 2021 by Member 15051539
How can i convert sql qury results to jsaon data for parsing Please share the examples What I have tried: How can i convert sql qury results to jsaon data for parsing Please share the examples
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...
29 Feb 2024 by johntk22
you have to try clear line or reset command on shell.
10 Feb 2014 by Sanjeev236
I want to rename file extension from *.bmp? to *.bmp .Sorry i tried a lot but being a newbie to linux. i need some help.19024380_fp_2.bmp? 19024532_fp_4.bmp? 19024673_fp_7.bmp? 19024813_fp_6.bmp? 19024380_fp_6.bmp? 19024532_fp_7.bmp? 19024674_17012014.jpg ...
13 Feb 2014 by Telstra
How to read oracle control file's data using a shell script?
17 Feb 2014 by JennyChua
Hi All,I need to extract the tar file into one folder based on original name.When I try this command, it shows this error;tar: mytesting201402070230: Cannot stat: No such file or directorytar: Error exit delayed from previous errorsMy commands;tar -cvzf...
5 Mar 2014 by Telstra
what is dos command to delete file contents only not the file?
18 Aug 2014 by Arun Kumar K S
I have created a C++ daemon in lunux ubuntu system. My daemon is implemented in such a way that the C++ executable is calling from a shell script in init.d. The daemon working fine on my system. But when I am stopping(sudo service mydaemon stop) the daemon it takes 10 more seconds to kill the...
2 Jan 2015 by Vidhya Raju
I have pandoc package in the path /root/.cabal/bin/pandoc. I couldn't to execute pandoc package through shell_exec() in php because of the root path.How to solve it??
24 May 2015 by Member 11714555
Hi guys, i am a very noob on Shell Scripting and I'm wondering if you could help me with some issues. I need to know users that are executing a watch command in the same computer in which 'MyOwnCommand' is beeing executed.I guess I have to use a grep command but I dont know how to use it....
11 Jul 2015 by Member 11744559
When I am trying create and send one /tmp/filename.txt to target server. I am not able process the file and It is not available in target server(It was not copied) but file has created in /tmp directory and data has copied. Note: file is not moving to target server directory. and I am running...
16 May 2016 by Валентин Ким
You need to write it that way:root@server:~# s1="$(echo 5)"root@vpn-1gb-nyc3-01:~# echo $s15So you'll need to rewrite your code like this:s1= "$(more /home/mohsin/Desktop/system_usage_bash_file | grep TIME | awk 'BEGIN {FS=","} {print $3}')"
21 Oct 2018 by P. Sachin
I am looking for batch file which will run and uninstall the Security update & Microsoft windows update from my server machine which I don't want to be there. As my server is supporting old technology app I don't want latest update after May 2018. Is there any way to do it. What I have tried: ...
25 Jul 2019 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 from column 1. When found...