A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.
1
vote
3answers
36 views
rename(1)-like script in Perl, but for copying files?
So there's this rename(1) Perl thing. It suits my task precisely, except that I need it to basically cp files instead of mv.
How to achieve that? I have quite a few rules of renaming, all expressed ...
1
vote
2answers
56 views
Wait until a process comes back from sleep
script.sh is run by run.sh N times in parallel. For N=1, the script.sh process is set to sleep 30-45 seconds before it actually starts.
How can I order ALL script.sh instances for N>1 not to start ...
-1
votes
1answer
29 views
How to record numbers of array elements based on selection comparision criteria
I have many files which has many 2x2 arrays. In the present example I show only one file (file1)
Input file(file1):
1: 6.1703
541.631 46.0391
2: 6.1930
537.446 45.9239
3: 6.1931
177.171 288.579
...
0
votes
0answers
17 views
Execute custom script when wireless NIC connects to SSID
I have pieced together two scripts that will serve to execute a custom script when my wireless NIC connects to an SSID.
Firstly, I will add the following (notice the post-up section):
auto eth0
...
1
vote
2answers
56 views
Copy files that are created today without FIND command and SFTP to another server
I have a directory with 'n' number of files in it. I am trying to write a shell script which will list only the files created on the particular day the script is running, and will use sftp to move the ...
0
votes
1answer
35 views
find: missing argument to '-exec'
this is my first post, as I am completely new to the programming world. Basically I'm taking a UNIX class and I have an assignment asking me to check the size of regular files in my home directory for ...
-2
votes
1answer
24 views
Unix shell scripting select and case statement
1) i want to write unix script which is like this
echo "Do u want to check application logs ???"
select opt in Yes No
do
case $opt in
"Yes")
commmands
;;
"No")
break
...
-2
votes
1answer
41 views
Write shell script for logging in servers and run command after logging in
I have wrote a shell script for logging into servers and run few commands to start and stop processes running on it, So I tried below code, but it is showing error, please help me with the script.
...
0
votes
0answers
34 views
wgetting links that are written in script form - not plain html
I use wget to download all the html pages in an online gallery - in order to grab all the links to the full size images as follows:
wget --wait=3 --user-agent=Webtography --no-cookies --timestamping ...
-1
votes
0answers
39 views
File edition after glob function through python
I wanted to find every instances of a file under different directories and search for value 0 in each of those files and replace them with 500.
Please find the code below
#!/usr/bin/python
import ...
1
vote
1answer
32 views
Convert GPS coordinates with bash script
I need to convert to a specific format some gps coordinates which are the output of the exif information of a picture.
This is the typical output:
exif:GPSLatitude: 10/1, 10/1, 10/1
...
0
votes
1answer
33 views
Read file upon .bashrc startup, based on date
I'd like to put a script in my startup that reads a line from a text file, and echoes this to the screen. However, I'd like a different line from the file based on what day of the month it is.
Thus ...
0
votes
0answers
19 views
Define root prompt and non root prompt in one rc file
I'm writing a restore script for my dotfiles and I find it really irritating that I have to have two .tcshrc for both root and user where they only differ by one line. Is there a way of defining the ...
0
votes
0answers
39 views
Curl command from shell script vs terminal returns 000 instead of 200 [closed]
I have script which:
Takes a set of parameters environment, id, ...
Generates url from those parameters url="'http://${host}/export/?id=${id}...'
Generates a file parameter file=${id}.xml
Runs curl ...
-3
votes
3answers
69 views
If, Then, Else Scripting
I have a log file that contains several lines, each with an IP, username, and URL. I need to create something that will take each IP in the line and, if starting with a 10 will append the word "ON" to ...
-3
votes
1answer
60 views
converting bash script to perl [closed]
We have a config file for different location, which we have to synced on daily bases, there are some files which need to be copied to a specific location & we have to edit the config file with the ...
1
vote
2answers
67 views
how to edit next line after matching pattern and append the line if doesn't exist
I am looking for changing a file content which is repeated twice with that replacement I want to add extra line to second content in the same file
Example file
User YOURNAME
IdentityFile ...
0
votes
0answers
13 views
Extract CSV gz file and convert to JSON
Is it possible to extract a CSV gz file stored on an external URL's public_html folder and then convert that data into JSON and then save it as .json in one command?
1
vote
1answer
25 views
Find and list duplicate directories
I have directory that has a number of sub-directories and would like to find any duplicates. The folder structure looks something like this:
└── Top_Dir
└── Level_1_Dir
├── standard_cat
...
1
vote
1answer
52 views
uniquely remove unwanted lines in multiple files
I need to remove unnecessary data from multiple output files
part of each file looks like this
# BLASTN 2.3.0+
# Query: M03117:99:000000000-ALL7G:1:1101:18697:4431_2:N:0:196
# Database: ...
-2
votes
2answers
37 views
Data Manupulation required your help
I have a data as mentioned below.
host_name Server1.domain.com
contacts DL - Desktop
contact_groups ravi, raj, rahim
host_name Server2.domain.com
contact_groups DL-Server
host_name ...
1
vote
1answer
33 views
Using Grep In For Loop
File1 contains:
421 RP-001
421 RP-002
421 RP-003
550 SC-001
550 SC-002
550 SC-003
550 SC-004
550 DY-001
550 DY-002
550 DY-001
550 OU-001
550 OU-002
Script:
#!/bin/bash
Elogs=/home/elogs.txt
...
0
votes
1answer
38 views
retrieve numbers with 0 for a single int value
In my script, I need to get a 0 for numbers <=9. When the user types any number, I add 5 to it and if the result is less than 9, I need to print a 0 in order to have a 2-digit number (like 07,08,09 ...
2
votes
1answer
17 views
Adding multiple comments to debchange in “batch mode”?
I'm trying to automate a deb package builder for a git repository, as part of which I want to get a bunch of commit comments (since the last package release) and put them into multiple comments in ...
4
votes
4answers
44 views
Running multiple programs in the background and checking their return value
suppose I want to run a few (say, three) programs at once, like this
program1 & program2 & program3 &
if I want to know their pid's, I think the best way is to store them, like this
...
0
votes
0answers
30 views
Significance of shell script with XML
I have recently joined anew project and experienced the structure where Shell scripts are usually directed to a target which is set in XML and that XML containing action in the tags which needs to be ...
-2
votes
0answers
18 views
Merge records in a pipe delimited files when first column value is same, based on the date field in the file
Sample File Input:
CustomerKey|EmailAddress|storeID|preferenceCd1|preferenceCd2|preferenceCd3|preferenceCd4|preferenceCd5|modifiedSystem|modifiedDate
1006374|[email protected]||2R05||||||2015-03-18 ...
0
votes
1answer
38 views
Bash script to install package if already not installed (From a directory with many packages) - Fedora 17
I have a directory full of rpms (And their dependencies). Currently I am executing yum localinstall ./packages_directory/*.rpm to install all packages in there. It automatically skips the ones already ...
1
vote
1answer
44 views
Is there a way to create a screen windows from shell script?
I am trying to write a script that creates a new screen session and creates 4 windows within it. I am able to create the screen session,
finding it difficult to find out how to replicate Ctrl+A+C, in ...
-1
votes
0answers
21 views
Loading configuration via putty
I have a NVR hybrid system that runs off of linux. Is there a way I could load a configuration file into this NVR via putty? Basically the file would be a snapshot of a finished NVR with the ntp set ...
0
votes
1answer
41 views
How to use TWO “for statements” in a shell script?
Writing script to create user accounts. Script is written to echo the useradd command (so I can make sure it will work as expected).
I have a file newemploy.txt with Employee Names (first and last, ...
0
votes
0answers
10 views
Automatically set Light and Dark Themes to interchange at Given times
I have a specific setting for my light theme and darker theme to use at night.How can I automate the interchange process.?
1
vote
1answer
79 views
Summarize certain data fields of apache CLF log file
I want to grep some information from raw combined log format apache logs:
51.254.56.62 - - [01/Jun/2016:20:49:28 +0500] "GET /vendors/jquery.slimscroll.min.js HTTP/1.1" 404 - ...
1
vote
0answers
30 views
Maintaining a window open until completion of another task [closed]
Aim: keep a GUI window open only for the duration of another command/script being run
Current Method for this: When current time matches command/script completion time, close the GUI window
I'm ...
1
vote
3answers
43 views
Help in separating columns from command into a new command
I'm a noob scripter, and I'm trying to create a script for automatic device creation.
I'm pretty far already, but I am stuck at one point.
The source file looks like this:
dev1 size 1024
dev2 size ...
1
vote
1answer
31 views
substitute at beginning of line
I want to search a pattern and insert a character at the beginning of a line using regsub in TcL. I have to use TcL only
Input file
mna1 x a1 vss vbn nch_svt_mac nfin=nfin_n1 l=ln1
mna2 x a2 vss vbn ...
1
vote
2answers
45 views
Compare string in two files And Merge its Output
I am trying to get the bandwidth of the domain from one file and its hits details from another file.
The format of the two files is as follows:
bandwidth.txt
aadrivingschool.ws 2840.36M
...
2
votes
4answers
55 views
How do i find over 200K differently named files and output
We have a SAN with a lot (over 5 million) of files. Because of some freak mistake from a developer script, some files have been deleted and we now have to figure out which files got deleted.
Now, I ...
-1
votes
0answers
23 views
Automating yum install using python
yum install (package-name)
How can I write a python script to execute the command above and see if its successful or not?
This should be the algorithm:
run command yum install <package-name>
...
4
votes
2answers
66 views
Rename Multiple files gzips them and delete older than 10 days
I'm new to Linux/Unix and slowly learning it step by step. Unfortunately on today’s job interview was surprised by a task to do (which of course I didn’t know). I was asked to prepare a bash script ...
1
vote
1answer
33 views
Point and click Ubuntu 16.04 bash script randomly alternates output behavior
I wrote and tested the following point and click Ubuntu 16.04 bash script for the purpose of completely killing a mono-service RecorderManager.exe process by literally killing the process id returned ...
3
votes
1answer
58 views
How variables inside braces are evaluated
I'm new to shell scripting and I came across these expressions
${var:-val} and ${var-val}
${var:+val} and ${var+val}
${var:=val} and ${var=val}
so how are they evaluated and what are the ...
2
votes
2answers
216 views
Run a ping command on list of servers and output to a file
I have a file servers.txt on a different server, with list of servers:
server1.mydomain.com
server2.mydomain.com
server3.mydomain.com
I want to first download this txt file, ping these servers and ...
2
votes
1answer
31 views
How can I use sed to snip a line off of a string?
I'm writing a script to display the domain registrar info and I'm trying to snip off a few lines from what I already have I currently have it grabbing all the indented text from a whois. Now I'm ...
1
vote
0answers
14 views
Change existing dovecot maildir installation from m-UTF7 charset to UTF8 to avoid breaking TAB
In an existing dovecot installation with many pre-existing folders using regional characters I would like to change m-UTF7 (.&AMk-l&AOk-ments envoy&AOk-s) foldernames to UTF8 (.Éléments ...
3
votes
1answer
32 views
How to automate mutt in removing old mailing-list emails?
In mutt I perform following sequence of steps:
$ mutt -f imaps://imap.example.com
username
password
[shift]+[D]
~C [email protected]
[shift]+[D]
~C [email protected]
(...)
[shift]+[D]
~C ...
1
vote
1answer
24 views
'xz -d' vs. `unxz`
Why is xz -d preferred over unxz when writing scripts?
From the man page for xz 5.1.0alpha:
When writing scripts that need to decompress files, it is recommended to always use the name xz with ...
1
vote
2answers
50 views
Use variables in here-string
To feed input to an interactive script, I've been using a here-string:
script <<< $'1 2\n3 4\n5 6\nq'
This effectively enters
1 2
3 4
5 6
q
into the script. But how can I replace one of ...
1
vote
2answers
30 views
Nautilus-script to move file into same name directory
How can I create a Nautilus script that moves a the selected file into a new folder with the same name?
My starting point:
/home/user/123
here 123 is a file with no extension
My goal here is to ...
3
votes
1answer
55 views
Join arbitrary lines to output as one line
I want to join the 3rd and 5th line of a file to the output of a script without trailing new lines.
Is it possible to implement this construction by using the code:
{
echo 'Some text'
echo 'Some ...