A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

-2
votes
2answers
95 views

How do you remove newline character in the middle of file?

File structure: Col1|Col2|Col3|Col4 123|456|abcdefg Tel.: 689346589934, xyz lckhasfkl|abc I want to remove the newline character from 'col3' only.Please suggest
2
votes
1answer
76 views

Regular Expression to match (not x) and y (!x & y)

I received a desktop day-to-day calendar with puzzles. One such puzzle was deciphering a quote where the letters were substituted with symbols. I used some RegExs to find longer words, then used the ...
0
votes
2answers
62 views

How to delete a line with a given word using SED function

I have a file .txt with inside ID VALUE test value_1 testing value_2 first value_3 second value_4 I'm trying to write a shell script which will delete a line corresponding to a ...
4
votes
2answers
145 views

How do I sync files between two drives?

What command can check that a directory contains the same files as another directory, all the files are up to date and copy any updated files or new files to the first directory. It should not care ...
0
votes
2answers
64 views

how to write python code to change display color

I want to change display color. I have a simple script: #!/bin/bash sleep 50 xrandr --output VGA1 --gamma 1.28:1:1.28 # for purple How can I write it in python?
2
votes
1answer
56 views

Run executable with variable in Bash

I have the following simple script to run an executable: ./executable.x -input input.dat << i input1 input2 i This works perfectly and all is right with the world. However, I would like to ...
3
votes
1answer
58 views

Allow only wrapper script but not command

Say one has a resource hungry command that users on a server need to run. I want to wrap said command with a wrapper script that will parse the arguments passed and ensure that the command is only ...
1
vote
1answer
78 views

mpack description (-d) from a script variable

In my script I have a variable named $message. I want to send this message together with a jpeg using mpack. One way that works: echo "$message" > myText mpack -s "test mail" -d myText ...
-1
votes
1answer
56 views

awk getline to display first three lines in file

I'm using awk 'BEGIN {while((getline gf < "awk.script") > 0) {print gf}}' to read me first 3 three lines of the pattern. I can do with head -3 . But I don't want to since, I have to switch ...
1
vote
2answers
60 views

Storing application passwords in central location

Is there any secure local service that one should use for storing and retrieving organization wide application passwords? Most of the time we need authentication information in our scripts to run some ...
3
votes
1answer
71 views

Split line to words of maximum size of 8 characters

I'm creating script that will display 2 times the song name in FM radio station name. Radio station name is limited to 8 characters. Lets say I have this line: Best Direction - I feel good The code ...
-1
votes
1answer
27 views

Comparing values in one same string [closed]

In my script, Im getting data from website, like that: content=$(wget 10.0.1.5:8000/currentsong?sid=1 -q -O -); It's basicaly song information on shoutcast server. But there is the problem: I like ...
0
votes
1answer
51 views

tftp non-intearctive mode not working

tftp inline not working root@kali:~/scripts/recon_enum/exploit-db# tftp -v 192.xxx.xx.xxx 69 -c get text.txt text.txt usage: tftp host-name [port] tftp> but its working in interactive mode: ...
0
votes
2answers
35 views

Writing a bash script on a new box, Escaping Code [duplicate]

There may be a question out there for this somewhere. But I wasn't able to find it easily. Basically I want to write a bash script on a new box. A script that I've previously used. Example: ...
4
votes
2answers
76 views

Redirecting bash loop output to variable specific files

this should probably be obvious to me, but I've been stuck for some time. I'm trying to write a very simple bash loop to take a list of servers, retrieve some specific info from them, and save the ...
0
votes
1answer
41 views

Measuring how much batteries lasts on another system? [closed]

I have both a Linux computer and Microsoft Vista laptop. I would like to know how much the batteries last on the laptop from the computer. How can I do a script for that, i.e. how to check on Linux ...
1
vote
1answer
25 views

Evenly allocate resources over multiple desinations

I'm not quite familiar enough with bash to figure this out properly, I'll try to be brief with what I'm trying to figure out! I have many paths stored in a file, along with their size (in G), such ...
2
votes
1answer
79 views

bash: if / elif / fi gets not evaluated properly

I've got a script which checks for a specific PNG file in three directories. The first one is local and gets checked first. The second one is a remote share and gets checked only if the file is not ...
0
votes
1answer
93 views

Script for renaming files using text file containing alternate file names

I have a folder containing thousands of files: file1.jpeg file2.jpeg file3.jpeg etc. I have a text file containing a list of new filenames I want to substitute: old_filename new_filename ...
1
vote
0answers
86 views

killall doesn't work if I call it from a script

I'm starting a tcpdump inside a script and I also kill it from the same script. So I'm currently using the killall command for this: The script gets executed from an udev rule: This is the section, ...
1
vote
1answer
26 views

Replace .vmdk for VirtualBox in bash?

So I have a external SATA adapter and a VirtualBox Windows 10 VM. I regularly swap in and out hdds that I want the VM to be able to access. Now I can create the vmdk with no issue with VBoxManage ...
0
votes
1answer
55 views

Runlevel script

I want to make a simple script so that the user can easy change the runlevels. The script should prompt the user to choose the new runlevel, run the /sbin/init program and receive a confirmation ...
0
votes
2answers
43 views

Remove both lines if column A values are repeated in next row

My input is like this: pak_c35079_g1_i1|m.14890 Pfam pak_c20797_g1_i1|m.3458 ProDom pak_c20797_g1_i1|m.3458 Pfam pak_c28265_g1_i3|m.9595 TIGRFAM pak_c28265_g1_i3|m.9595 ...
1
vote
1answer
20 views

Rename files to insert _ between StudlyCapsified words

I've a music lib where files names are like 05WithoutWallsSpanishMixChillDeLucia.mp3 (no space between words BUT exist a capital letter at beginning of every word). How do I detect this string form ...
3
votes
3answers
21 views

jump to current day's directory in a date based directory hierachy?

I have a pretty standard directory higherachy, year, month, date, for log files. If I want to go to todays logs I have to type cd logs/2015/12/16/ By itself this wouldn't be bad, but since I ...
2
votes
2answers
43 views

Check Input Prior to Executing a “for loop”

is there any way to check or test the input from a 'read' against a for 'loop'? I don't want the case statement to execute there any of the input is incorrect. As of right now it will loop through, ...
-1
votes
1answer
53 views

Trying to sum a decimal column from a csv file for each different vendor

I am new to Unix/Linux and am trying to sum a column for each vendor in a loop. I apologize for the vagueness. I will try to explain. It is suppose to read from a file and based on the vendor name ...
3
votes
2answers
63 views

Changing file permissions according to their names

I created 512 files, with names made from combinations of permisions (r, w, x). I created them like this: touch ./{r,-}{w,-}{x,-}{r,-}{w,-}{x,-}{r,-}{w,-}{x,-} and I want the files to have same ...
1
vote
1answer
27 views

How to put the percentage of use of each core from cpu

I use the Zabbix Server to monitor my environment. The metrics used by Zabbix to view the CPU are too confusing, so I would like to simplify. Is there a way to get the percentage of use of each core ...
0
votes
1answer
105 views

Pipe openssl input to bash script read

I need to pass input from my bash script to the commands I run inside the script. I have no idea how to do it. I've searched all day for something like this in bash. #!/bin/env bash # This script is ...
0
votes
1answer
45 views

awk script to extract the argument of an option

Can some one explain what the awk '{for(i=1;i<=NF;i++) if($i~/-f/) print $(i+1)}') part does in the following snippet line='/wwws/apache/apache2.4.16w-r01/instroot/bin/httpd -f ...
0
votes
1answer
141 views

shell find -delete “directory not empty” [duplicate]

i try to delete backupfiles on my synology nas older than 30 days, the files are in a directory which is created durig downoad the backupfile from my webserver after download i want to check -mtime ...
0
votes
1answer
69 views

Can not execute bash script (unexpected element '(' )

I have created a script to check if I have installed Node, Npm, Bower and Susy but when I execute it I get an error which I can not solve. This is the script: isInstalled(){ command -v $1 ...
0
votes
1answer
52 views

Where is my .sh script syntax error(s)?

Trying to run a small simple script to pull the java -version information from an AIX system's several java64 folders piped into an output/log file using the system's hostname but can't seem to get it ...
4
votes
5answers
104 views

Best way to partially step through a 25k string?

I have a 25k characters. I wish to write a script to print (printf is most portable I'm told) an arbitrary number of characters; stepping through them in order. say: command number Where number ...
2
votes
1answer
36 views

Is there a way to create endless stream with custom character?

I need to create an endless stream of characters like /dev/zero but I need it to spam custom character (like 'a') instead of 0x00. Is there a way to do it?
0
votes
0answers
26 views

start-stop-deamon not stopping instntly after start

I made a script A to start script B as daemon. I can see it starts the script B correct, but script B stops almost instantly. I confirmed that script B itself is working fine, so it's not the case. ...
0
votes
2answers
52 views

Parsing a Blocked file and generating smaller files

I have a file like below: 1weather dnsndjsdn 2nm bdbdb bdbdbdbdnnd 3gfdu hsihdishdis 5 1hdohdsohsoihssodhoishs 2nfdksnkdsnfsdsjndkdj 3kjdscdskndskjndndsdsdsd 5 Like wise I might have close to ...
2
votes
3answers
356 views

Validating IP addresses (IPv4 and IPv6)

Quite simply I'd like to verify that a string represents a valid IP address in a bash script. I think like many others I've fallen into the pitfall of trying to do this with a regular expression; ...
0
votes
0answers
35 views

FORENSIC PURPOSE - Acquire Android image using flash drive OTG

In Linux, the dd command is used to pull the image from the smartphone to computer. And of course, the smartphone need to be rooted before the dd command launched.From the research i do and multi hand ...
0
votes
0answers
12 views

in sh script , what is the - sign for after a variable name? [duplicate]

$mtdnum is a string, could be null string. What is the - for? if [[ -z ${mtdnum-} ]]; then echo "Could not find it" return 1 fi
1
vote
1answer
49 views

Linux bash script input without using “read” [closed]

I need to create a bash script where a single argument is passed by the user (without using the "read" input option) at the terminal command line that creates a directory with that name, or otherwise ...
1
vote
3answers
86 views

Bash - Perl Script variable insertion

I'm having some troubles trying to insert a bash variable inside my perl code. The purpose of the code is to execute a certain perl printing command into a terminal using a bash script file. I have ...
2
votes
1answer
95 views

Possible race condition when scripting headphone plug-in event

I'm currently trying to script the headphone plug-in/out event. I found out that I can script this quite easily as an acpi event.. I created a file in /etc/acpi/events/ with the event event=jack[ ...
1
vote
1answer
113 views

Apply SHA256 and Base64 to string in script

I'm trying to apply SHA256 and then Base64 encode a string inside a shell script. Got it working with PHP: php -r 'echo base64_encode(hash("sha256", "asdasd", false));'. But I'm trying to get rid of ...
-3
votes
1answer
38 views

Script Help _ Enter Greeting “hello” _ Echo Hello

I am looking for some basic script help that I can fine tune. Basically I am looking for a script that does this: ./greeting.sh :Enter Greeting User input "good morning" Script: Echo "hello ...
-1
votes
2answers
25 views

find the directories not in argument list [closed]

Can anyone pls help me in finding the directories not in the list. Suppose I have the following directories: opt cmd XX I need to get all the directories not in the above 3.
1
vote
3answers
103 views

How to add tag for xml from file exist using shell linux

xml1.xml <app> <bbb> <jjj>test1</jjj> </bbb> <bbb> <jjj>test2</jjj> </bbb> </app> xml2.xml file2 ...
0
votes
1answer
64 views

How to reboot the machine when it hangs?

I would like to know how I can detect when my machine hangs. Let me explain: I always need to run several C programs on my machines (Ubuntu 14.04, 15.04 and 15.10). These programs often hang after a ...
1
vote
1answer
18 views

Why won't this example of setUID work? [duplicate]

I am learning about setuid and setgid where the user executing the script will inherit the owner's permission while running the script. To test this, I created a bash as user fiverr in ...