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)

0
votes
1answer
51 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
99 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
24 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
51 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
131 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
28 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
38 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
33 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
46 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
54 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
35 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
24 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.
2
votes
3answers
56 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
63 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
16 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 ...
1
vote
2answers
75 views

Shell script to kill processes except those owned by user

I am Looking for some help in creating a script to kill processes, but return an error message if they are owned by root. Firstly I would like to say that I am a total beginner at this. At the moment ...
1
vote
1answer
15 views

Which executable is called if called within script via relative path?

Say I have this script mm in dir1: #Contents of mm echo "Hello Main!" ./hd My pwd is dir2, and I now execute mm: $ ../dir1/mm There is an executable named hd in both dir1 and dir2. I tried it ...
0
votes
0answers
15 views

Run script on headphone plug in/out event [duplicate]

I'm trying to run a script on every headphone plug-in and out event. For instance mute the sound (with amixer) when the headphones are plugged out. I don't want to limit these scripts to sheer volume ...
1
vote
2answers
18 views

How to parse output for a specific response (creating Extension Attribute for JAMF JSS)

We recently got JAMF JSS for our organization to manage our Macs, and I'm trying to make a script for what they call an Extension Attribute (basically a custom inventory record field). What I want is ...
0
votes
2answers
48 views

Conditional grepping

I have a scenario to handle. Need help with that... I have a config file and its content looks something like below: Jobname|Type|Silo|Description #comment1 #comment2 ...
1
vote
5answers
109 views

How can I get the number of spaces characters in a string?

How can I check how many white spaces (' ', \t) there are in the first line of a file? Thanks
0
votes
1answer
128 views

Can I see always time in console?

I would like to set the Linux console such that it shows the current time always in console's upper right corner. Is that possible to do? Or is it wise to do if one can never be sure if the cursor is ...
1
vote
1answer
26 views

Trigger certain events for devices

I would like to know if it's possible to setup special trigger events for devices when plugged in and/or unplugged from the system on the fly without needing to configure it every time the device is ...
1
vote
2answers
44 views

Merging two files using scripts

I am trying to merge two files of different lengths using a script. I want the longer file to be appended to the end of the shorter file and when both files are of equal length they are suppose to ...
0
votes
0answers
21 views

How to display the total number of fields in the file, excluding the first and last fields of each line.

command : nawk '{print NF}' filename | grep -v '{$1 $}' I tried this and a couple others in my script but I haven't figured it out yet i tried cutting the first and last line by doing nawk '{print ...
0
votes
1answer
22 views

How to write a nawk script that prints out all except the blank lines and displays the total number of blank lines?

I have tried a couple different things but I cannot get it to work. Mainly I'd just like to know how to exclude the blank lines. command tried : nawk '{print $0}' filename | grep -v " "
0
votes
1answer
20 views

Script for backup each DB on server but omit system databases

I have read a lot of post around this topic but I didn't found the one to fit my needs. So, basically I want to make two backups: one at mid day (12 PM) and the other at midnight (12 AM) for each ...
0
votes
0answers
44 views

Make whiptail work in a for loop

This is my first question ever here... So please be gentle :) I have a bash script that checks ping for 163 sites(stores around the country), which is this: #!/bin/bash #storestest.sh #version 0.9.2 ...
1
vote
1answer
68 views

Crontab and Tmux not playing well together

So I want my server to run a script which starts several tmux sessions on boot. This is my crontab: @reboot . /home/steven/.profile; /home/steven/Scripts/Start.sh And this is the content of my ...
0
votes
0answers
28 views

Creating a for loop in bash to analyze two data files and create an output sorted by the phone numbers? [duplicate]

I have two data files that I am trying to create a for-loop that will analysis both data files and create a script that will produce an output that looks like the following. I am having difficulty ...
0
votes
1answer
27 views

data from text file in a form of text

I have multiple directories (different names) which contain text files of he same name. I have to extract lines (numerical values) from those text files and create a single text file with a list of ...
3
votes
1answer
30 views

awk not doing a new line

I'm trying to print out the users who are currently logged in (each logged in user of each terminal). This is what I currently have: NOWDATE=$(date +"%Y-%m-%d") NOWTIME=$(date +"%T") USERS=$(who | ...
8
votes
4answers
373 views

Compare two URL lists and print newly added URLs to a new file

I am initially producing two files which contain lists of URLs—I will refer to them as old and new. I would like to compare the two files and if there are any URLs in the new file which are not in the ...
0
votes
0answers
44 views

how to reverse check mount command options from mount list?

let's say i use this command to mount: $ sudo mount -o nolock 10.8.4.3:/opt/example /tmp/mnt Then i can use mount to get the mount details: [xiaobai@xiaobai self]$ mount | tail -n 1 ...
6
votes
3answers
375 views

Can I have a variable in a Bash “for loop” condition/sequence?

I couldn't think of a better way of wording the question title. I know there has to be an easy answer or simple alternative to doing what I'm trying to do, but I just cannot come up with anything at ...
1
vote
2answers
20 views

Run script on startup for Old Linux kernel (3.0.0)

I need to run a script on system startup, but the Linux version is very old, so: There is no rc.local. Even when I created it and gave it a command, it was never run. There is no crontab at all. ...
2
votes
2answers
62 views

Trying to convert a simple C program into an AWK program

Hey guys a couple of weeks ago I wrote a C program that prompts the user for the name of a text file and then prompts the user for a word. The program then outputs the input text file with numbers to ...
4
votes
5answers
76 views

Count unique associated values in awk (or perl)

I've already found "How to print incremental count of occurrences of unique values in column 1", which is similar to my question, but the answer isn't sufficient for my purposes. First let me just ...
5
votes
1answer
127 views

Sort output of awk except for first line?

This is a use case I am continually running into in parsing CSV files. When it is an inline awk script embedded in a shell script, I can use this workaround: myfile=$(mktemp) awk '(awk script here)' ...
0
votes
1answer
22 views

Append one file to two files in unix script [duplicate]

I need to append one trail record to both the files. cat file1 >> file2 this appends everything in file1 to file2 My requirement is to append to file1 content to both file2 and file3.
2
votes
1answer
33 views

Is there any danger to using an unset variable in a bash function definition?

Doing some code refactoring, and I realized I don't know if this matters at all: The function definition is going to be sourced from another file (a sort of library). The function uses certain ...
2
votes
1answer
52 views

How to enter a sum derived from awk in the middle of text output [closed]

I am trying to print a sum in the middle of a line. My script prompts for a user name and then pulls a total number of processes and a total of time for that user from a file. I want to print a ...
2
votes
3answers
123 views

Source only part of a script from another script?

This would probably never be the BEST approach to something, but I'm wondering if it's even possible. Something like: awk '/function_i_want_to_call/,/^$/{print}' script_containing_function | xargs ...
6
votes
1answer
142 views

Replace current process by its coprocess/child

I have a program P that expects to receive "Hello" and output "Why?" before providing a feature. This feature is used by other programs that are not aware that it is common courtesy to start a ...
1
vote
2answers
111 views

How to call bash function from within awk?

This is a bit tricky; I'm trying to work out the best approach to this problem. I have a couple of approaches, but they seem really hacky and I'd like something a little more elegant. I want to ...
3
votes
2answers
72 views

Bash Scripting: How do i limit the amount of options in a select loop?

When you use the select loop to present the elements of an array as an option, it will display it all at one time. Is there a way to present the options to the user for like 25 options at a time?
1
vote
1answer
45 views

How to create shell script to handle commands like ls -l /somedir

My script so far can handle the ls command and returns the files in the directory. Now i am trying to make it handle commands like ls -l /tmp . Any help? My script so far: #!/bin/bash #set -x clear ...
3
votes
2answers
65 views

How to keep exactly one file in a directory?

I have recovered files and currently they have this structure: root/MD5_of_file1/file1 root/MD5_of_file2/file2 ... root/MD5_of_filen/filen Obviously, duplicates are now in the same folder. The ...