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)

-4
votes
0answers
40 views

What am i doing wrong with my script?

#!/bin/bash echo echo These are the Users Processes top -b -n 3 | sed -n '6,12p' pid= top -b -n 3 | sed -n '7,12p' | cut -f1 for pid in 'ps -ef | grep $pid | awk '{print $2 }'' ; do kill $pid ; ...
-1
votes
0answers
33 views

Writing a shell script into startup file .profile [on hold]

I need help printing any one of the following messages using echo statements as soon as I logon to the system: "Good Morning", "Good Afternoon", "Good Evening" according to the system time. I could ...
1
vote
3answers
35 views

Difference between sh -x and ./ for script execution

So I have a simple shell script. What is the difference between the two commands in execution? Is there a preferred way? $sh -x foobar.sh OR $ ./foobar.sh I found the script executed slower when ...
0
votes
3answers
62 views

Remove lines in a shell script

I have this file: # more file.txt 2c2 lns-ld-wall-01-t2 old:261,260 4c4 Prive_ORANGE old:258,259 I need to remove all lines like this one 2c2 and this one 4c4. How can I do in a shell script?
-2
votes
0answers
20 views

Sending a command through e-mail [on hold]

What the script can be, if I am sending an e-mail to an e-mail address in a format of: From:<addr> Subject:<cmd> <input> ... ? Script will run a command <cmd> and to ...
0
votes
1answer
21 views

Filtering Log Output on Separate Lines

I did a recursive grep in a directory to find all files that would match as follows grep -ER "match_string1|match_string2" /path/to/dir/ What I get as output is: ...
2
votes
1answer
29 views

Shell Scripting: Deleting or moving files from one directory that match filenames from another directory

I have a very specific and odd problem to solve. I'm working as a research assistant and I've been producing a ton of figures. In one directory, I dump .pngs to view casually (limited space here) and ...
-2
votes
2answers
60 views

Parsing a flat file using shell script

I have a file like in following format User:blala Pass:blala IP:***.***.**.** I tried with IFS but it is not working input="/path/to/your/input/file.cvs" while IFS=',' read -r f1 f2 f3 f4 f5 f6 ...
-1
votes
0answers
6 views

rpm package not updating as I update the spec file

I have some statement the %post section of my rpm spec file of the form echo "printing A" I updated the spec file to make it "printing B" but the new rpms I'm creating still echo "printng A" What ...
0
votes
1answer
24 views

How to execute several lines into a .txt

I am using SSH; In a folder I have the next files: -rwxrwxr-x 1 german german 48 Apr 29 10:45 prueba.txt -rwxrwxr-x 1 german german 23 Apr 29 10:43 script1.sh -rwxrwxr-x 1 german german 23 Apr ...
0
votes
1answer
37 views

Script for update

I need your help in a script used for update : OLD="int 10" NEW="int 20" i=0 DPATH="/home" for f in $DPATH do sed -i "s/$OLD/$NEW/g" $f let i++ echo "modified:" $f done what i need ...
-4
votes
0answers
35 views

How do I write these three scripts to do the three functions? [closed]

Section 1 scenario – The user is hung and calls the help desk for help. The script run by Help-Desk personnel will operate as follows: The script will display all processes owned by the user At some ...
2
votes
2answers
36 views

Does zsh expansion work differently in non-interactive scripts?

I'm currently working on a pretty simple zsh script. What I often do is something like: mv */*.{a,b} . When I run that within a zsh script, it seems to expand differently and fail while it works in ...
-3
votes
0answers
21 views

Duplicate Image Searcher using Bash [closed]

I need to create a script to search through a directory (and sub-directories) of a user’s choice, creating a SHA1 hash value for each image. Each calculated value will need to be compared, where the ...
0
votes
2answers
29 views

Add some text while output to file

Assume I have this command: ./clang-$j.out >> clang-result.txt and the each output for clang-$j.out is a fixed-length hash value (each program per line), however, I want to distinguish them by ...
3
votes
2answers
43 views

Detect and respond to ping in userspace

Is there a way to make a linux system react or do something when pinged from another device, besides just sending a reply (or not)?
9
votes
2answers
405 views

Jump out of a process when it get stuck

I have written a loop to iterate all .out c binary file and copy their outputs into a text file (the output for every binary file is just a one line hash value, one line output for one program). Here ...
2
votes
1answer
21 views

How do I detect which device was recently created by pppd?

I'm trying to setup a VPN over SSH using PPPD (following the Arch Wiki). The command given is: /usr/sbin/pppd updetach noauth silent nodeflate pty \ "/usr/bin/ssh root@remote-gw /usr/sbin/pppd ...
2
votes
1answer
41 views

How do you make a toggle key using Autokey?

I want to use Autokey to toggle the e key on and off in a program called "xyz". So if I press e, the program thinks I'm holding down e. I press e again, it thinks I released it. How do you do this ...
1
vote
1answer
47 views

Extracting duplicity backup data

I've made some backups of my previous systems using Deja Dup (duplicity). In my current distribution it's not available, so I've simply extracted the data. Now in order to make that data meaningful ...
0
votes
1answer
71 views

Run script on multiple hosts [duplicate]

I have below script which creates user list and also filters ignore.txt file to ignore matching usernames. I would like to run this script on multiple hosts like hostA, hostB, hostC. Like if I run on ...
1
vote
0answers
14 views

Run a script on window focus [closed]

I have a wacom tablet and I'd like to change the button configurations when I change applications. I figure I should run a script to override the previous xsetwacom configuration every time the focus ...
1
vote
0answers
21 views

Need help with a network manager command line script

I am looking for some help in creating a script. As RHEL boots up and I login, I'd want to manually run a script which would: Identify the active ethernet interface (the eth ID being used). Ask ...
-3
votes
3answers
60 views

Delete line from files

I have 8 files in a folder. If any of these files has 2 lines I need to remove the second line from that file. If a file has more than 2 lines then then I do not need to do anything to it. Can anyone ...
1
vote
1answer
31 views

delete redis keys that have been inactive for 30 days

I've installed a web app called scrumblr which uses redis as a database. What I am attempting to do is delete all keys that have been inactive for 30 days, or have not been accessed in 30 days. I ...
2
votes
2answers
68 views

Change Password Programmatically

In the current version of Raspian, I know it is possible to change the password of the current logged in user from the command line like so: sudo passwd which will then prompt the user to enter a ...
1
vote
0answers
20 views

How to disable AC power supply from CLI

This article among others suggested the following to prolong battery life: Keep cool. Operate in mid SoC of 20–80%. Prevent ultra-fast charging and high loads (most Li-ion) The main issue here ...
1
vote
1answer
21 views

How to change configuration of detox (dash instead underscore)?

I found, best to this moment, a solution when changing all those annoying filenames in large quantities, making them readable and easier to manipulate with in command-line. So I found, among many ...
0
votes
1answer
34 views

Filter grep output

Using grep "val" index.php I get the list <td class=val> 7.6</td> <td class=val> 58</td> <td class=val>1013.8 </td> <td class=val> 1020 </td> <td ...
0
votes
1answer
18 views

Connecting to Windows server from unix through script

I am trying to connect to a Windows server say 10.1.1.10. This servers has a folder named RAJ in which there are multiple .zip files. All these zip files contain a text file called XYZ.txt. Now i have ...
0
votes
1answer
64 views

How to parse an awk variable

I'm trying to pull some information out of a log file, looking back over a specific period of time (e.g. the past hour). I've found the following awk construct that works, capturing the data as a ...
0
votes
2answers
34 views

Change only the year on the output of the “date”-command

date for example displays Fri Apr 17 20:16:01 IST 2015 Now I want to change only the year so date should display Fri Apr 17 20:16:01 IST 2016 in this example. How to add 1 year to the output of date ...
2
votes
3answers
65 views

Command line options with argument in shell script

I have a script to get ldap user name, email and mobile number: #!/bin/bash echo -n "Enter Unix id > " read UNIXID ldapsearch -x "(cn=$UNIXID)" | awk '/givenName/||/mobile/||/mail/' Here is the ...
4
votes
2answers
193 views

Best and short way to run a program if another is not installed

I have this code: #!/bin/bash num=${1:-undefined} cmd=$(which {banner,echo} | head -n1) until [[ "$num" =~ ^[0-9]+$ ]]; do read -p "Type a number: " num done for ((num;num>=0;num--)); do ...
2
votes
1answer
44 views

Storing one bit of information in user space [closed]

I'm writing a program that collects network data. I need to store one bit of information, a simple yes/no, somewhere so another process may read it. I have several options: writing a 1 or 0 to a file, ...
0
votes
0answers
21 views

Create complex installation script for Linux (Centos)

For deployment of a complex system I would like to create a script that runs all compilations and set up. I am looking for an existing product that interpret installation scenario and performs all ...
0
votes
0answers
43 views

Need to have password coded in script [duplicate]

I have to login many Servers day in day out by supplying passwords manually. Now I want to know or have a script where from I can login to any server without password (I mean to say if the ...
3
votes
0answers
28 views

Automatically restarting process in the X server

I would like to know how to have a process that starts with the X server and automatically restarts when it stops running. I am running Ubuntu 14.04 with a KDE 4.13.3 desktop. I am running the ...
0
votes
0answers
17 views

check media resolution if resolution is big ffmpeg it, if output is smaller than original delete the original else delete the output

I have my storage VPS filled with videos, and hoping I can free up some space, their resolution is pretty big so I decided to re encode them with ffmpeg to a smaller resolution, I am doing every thing ...
3
votes
3answers
71 views

How to run a script on a remote host when I lose connection to it?

I'm working with the BeagleBone Black, which runs Debian Linux, and sometimes I will lose wireless connection to it while I am testing my programs. This wouldn't necessarily be an issue on its own, ...
0
votes
2answers
46 views

How to search recursively in a directory for different files?

I have a x.tar file in directory /a. After untaring x.tar I got the following result: cust/ cust/01/ cust/01/INFENG/ cust/01/INFENG/scr/ cust/01/INFENG/scr/test.scr cust/01/INFENG/SQL/ ...
2
votes
3answers
104 views

remove all instances of _000 from multiple files

Had to recover my music library from a HDD which died.... got everything I wanted but all music track names have _000 added at the end. I really don't fancy going through 8000 individual music tracks ...
1
vote
1answer
98 views

Sed command that would ignore any commented match

I'm trying to create a sed command using regex in order to substitute something in a text file only if it is not commented but I'm running into some troubles due to my almost non-existent knowledge of ...
4
votes
2answers
101 views

Safely exiting while loops in bash

Say I have a bash script that does: while : do foo done I would like to be able to run this script from the console and be able to exit it at an arbitrary time as long as it happens in between ...
2
votes
3answers
176 views

AWK & Bash: Checking that a User's Home is Owned by the User

I'm trying to cycle through /etc/passwd with a single-line command in order to find those users who have a home directory which is not owned by the user, but I'm VERY new to bash programming, and I ...
1
vote
1answer
37 views

Displaying “No Results” When AWK Command has no output

I have the following code, thank-you to the people who helped me here awk -F: '{if(system( "[ -d " $6 " ]") == 1) {print "The directory " $6 " does not exist for user " $1 }}' /etc/passwd However, ...
1
vote
1answer
48 views

shell script for date checking between two days

There is date in my file, like 30-apr-2015. How can I compare this with the current date and get notified if they are equal?
-1
votes
2answers
41 views

Linux Bash Scripting Issue with Wildcard

I'm having issues with what I imagine should be a simple bash command I'm basically just trying to loop through a bunch of files and get there names `ls ./*.sql` # list all files ...
0
votes
2answers
35 views

How to scrape multiple IP's and add in a script as a variable?

I am trying to add in my script an awk statement or a: if; else; then if eth0:4 is a match then put in eth0:4 IP How would you get the IP in your script as a variable if you have multiple IP's ...
1
vote
1answer
42 views

Rsync Excludes Folders

I am running a rsync script and I want to exclude certain folders. I know with rsync you have to create a .txt file and add all the excludes in there but I am wondering is it possible to just have a ...