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 (1)

3
votes
1answer
87 views

Preserve formatting when command output is sent to a variable? [duplicate]

I have a bash script. If I run this command to: grep for certain patterns, transform the output, sort the output dedupe the output then I get one grep find per line in terminal LC_ALL=C grep ...
2
votes
2answers
45 views

split a file, pass each piece as a param to a script, run each script in parallel

I have a words.txt with 10000 words (one to a line). I have 5,000 documents. I want to see which documents contain which of those words (with a regex pattern around the word). I have a script.sh that ...
-2
votes
0answers
23 views

Modify Perl Menu [closed]

Here is my code so far: #!/usr/local/bin/perl -w use strict; use Cwd; while ( 1 ) { print "\n COMMAND MENU\n"; print "\n a. Current date and time\n"; print "\n b. Users ...
0
votes
0answers
28 views

bash script loses readonly value after first time thru loop

I have a bash script which seems to lose the value of the readonly constant after the first time thru the for-in loop. For example: #!/bin/bash readonly DIR="./groups/" for output in "${array[@]}" do ...
1
vote
3answers
53 views

List all the html tags in a file

I want to know if there is a way to list all the html tags in a file. Lets say I have a file file.html <html> <head> <title>Test</title> </head> <body> This is a ...
2
votes
2answers
29 views

I seem to be “losing” this prompt. What is happening?

I ssh into an ubuntu 12.04 cloud server and start a web server like this (w/ bash): $ nohup python tserver.py & [2] 2122 $ nohup: ignoring input and appending output to `nohup.out' After I run ...
1
vote
2answers
169 views

How to iterate through multiple file extension without caring about case sensitivity?

I've seen various topics on how to iterate through multiple file extensions but in most case, the list is defined. example: for file in ${arg}/**/*.{txt,h,py} do .... done As can be seen, ...
5
votes
3answers
181 views

How to iterate through a list of files with spaces that is sorted (case insensitive)?

I am doing this in OSX which uses bash but obviously, not all bash conventions are used so hopefully your suggestion is available to me :) I have the following files fun bar1.txt Foo bar2.tXT ...
2
votes
1answer
26 views

Fetching Remote Windows System Information From Linux Server

I need a script/command that would fetch Windows System Information (Host Name,User Name, Domain, OS Info, Hardware Info, Memory Info, processor Info, etc) by running it on a Linux Server (RHEL 6.5 ...
6
votes
2answers
68 views

Passing arguments from a file to a bash script

I' ve got this situation: ./ ./myscript.sh ./arguments.txt ./test.sh Inside myscript.sh, i have to run the file test.sh, passing to it the arguments contained inside arguments.txt. myscript.sh is: ...
4
votes
3answers
245 views

awk with if statements

I am trying to print from a file using awk, but my output is empty. Here is my code so far accountNum=$1 while read -r LINE || [[ -n $LINE ]] ; do awk -F',' '{ if($1==accountNum) { print ...
2
votes
2answers
47 views

Renaming the files and move to other path

I need to rename the files given below and move to some other path 1234551abcde20140718023216001.txt.809047512.2014_07_07_13:47:44 000001abcde20140718023216001.txt.34568.001.2014_07_07_13:50:44 ...
1
vote
0answers
28 views

Converting .docx files to plain text and preserving line breaks to maintain line number references to source document: howto & implications?

I'm exporting MS Word content to plain text for use with text&file utilities. I have a constraint where the line numbering feature has been enabled in the MS software, and any reference to line ...
0
votes
2answers
66 views

Solution to integer expression expected [closed]

So I when I run this code on my mac there are no errors, and it provides me the perfect output. But when I run it on Ubuntu or CentOS i get the following error integer expression expected ...
3
votes
1answer
28 views

Copy image from clipboard to file

Is it possible to take an image from the clipboard and output it to a file (using X)? I can do this with text easily: $ xclip -selection c -o > file.text But when I try the above with an image ...
0
votes
1answer
29 views

Reusing user input in a script

I have the following script which works: #!/bin/bash xfreerdp /cert-ignore /f /v:farm.company.com /d:company.com /g:rds.company.com /u:$(zenity --entry --title="Username" --text="Username") ...
2
votes
2answers
50 views

Pass argument to script, then redirect script as input to bsub

I am currently working with the bsub job submission system from Platform LSF. I need to submit job scripts, but I am running into a problem with passing arguments to the job script. What I need is as ...
3
votes
1answer
49 views

Run command based on output of another command

OS: AIX 7100-04-1216 So basically I'm trying to write a for loop that sees which volumegroups I have on my system, which filesystems reside in those volume groups and what the size of each of those ...
0
votes
2answers
100 views

If UID=1000 continues, else exit

I am wondering how to implement the following in a bash script. if UID=1000, continue else exit confirm choice (y/n)
3
votes
1answer
105 views

Converting and rescaling a lot of png images to jpeg

I have a lot of .png images in a folder. Is there a command (or software) that can convert all them to .jpg and (simultaneously) rescale the created .jpg files to 25% of their original size?
2
votes
3answers
57 views

How to add a new line for a missing entry between two fields

I have this file. As you can see in column1, entries TEST01N03, TEST01N06, and TEST01N18 are missing (total of 18 entries). Is there a way to check the fields of this column and fill in the missing ...
1
vote
1answer
38 views

Why does the same sed regex (after grep) fail when run in a bash script vs bash command line?

Here's the script. It is successful when I run it from the BASH prompt, but not in the script. Any ideas? When I say "fails," I mean the sed regex doesn't match anything, so there is no replaced ...
0
votes
2answers
56 views

How to count number of instance of a word starting at another word

I need to grep the MySQL-error log starting at today's date formatted like: `date +"%y%m%d"` (140710) And look for all instances of the word partitioned. I've tried various things to no avail. ...
1
vote
1answer
55 views

How to run java service as a non-root user on CentOs 6

I have a script that starts a Java application as a service on CentOS 6: #!/bin/sh # chkconfig: - 80 20 SERVICE_NAME=cn4server PATH_TO_JAR=/usr/local/share/myserver/cn4server.jar ...
2
votes
0answers
10 views

How can I run a KDE plasma script from command line without GUI?

I want to run a plasma JavaScript file from command line, but the only solution I found so far involves a graphical script editor and requires a user interaction to run the script: qdbus ...
0
votes
1answer
42 views

Converting windows date logic into Unix [closed]

I had coded the below logic in Windows batch scripting and I need to replicate the same in Unix. # Calculating Yesterday's Date for /F "tokens=1-4 delims=/- " %%a in ('date/T') do set DY=%%c for ...
1
vote
2answers
65 views

SCP Automation in production environment [duplicate]

I want to implement the use of scp command in a production environment. I don't want to provide my password in the automation script. Is there any way? I need step by step solution.
1
vote
2answers
85 views

Shell Script - how to scp into remote server and download files and protect password

I have a remote server that I need to download Apache logs from. I can manually scp into the server and get the files, but I'd like to put this in crontab. The only way to automate it is to include ...
1
vote
1answer
33 views

failed to stuff “ctrl-a H” to a screen session

I need to toggle logging from outside of a detached screen session. Interactively you do this by pressing ctrl-a H. Their octal codes are \001 and \110. (source) What I tried: $ screen -S test ...
0
votes
1answer
39 views

Configure localtime. dpkg-reconfigure tzdata

I'm using this to configure localtime: dpkg-reconfigure tzdata It is ncurses interface. I'm looking for the way to programming this. Is there true way without user ncurses interface? How to ...
3
votes
2answers
45 views

The reverse of `tree` - reconstruct file and directory structure from text file contents?

We all know we can use tree to get a nicely formatted text "visualization" of the structure of a directory; say: $ tree -spugD /usr/include/boost/accumulators/numeric/ ...
1
vote
1answer
54 views

Run terminal commands from within LibreOffice's Basic programming?

Is there a way to run system commands in LibreOffice Basic macros so that macros will be able to do things outside LibreOffice (e.g. changing keyboard layout)?
2
votes
1answer
112 views

Convert xml subtitle file to srt format

I have a xml subtitle that looks like this: <?xml version="1.0" encoding="utf-8" ?><transcript> <Item from="1.16" duration="4.68"><![CDATA[(Dong-hyuk is coming to see you now.) ...
2
votes
1answer
45 views

diff two directories for changes and format output to use for script

I currently try to monitor two directories and subdirectories for changes in files. The directories contain the same set of files, some of them are changed. So I thought I might use the diff command ...
3
votes
1answer
50 views

Launch RDP silently?

I currently use the following command to launch an RDP session which works fine: rds@rds:~/Downloads/FreeRDP$ xfreerdp /v:farm.company.com /d:company.com /g:rds.company.com /f /u:username /p: At ...
2
votes
1answer
132 views

What is the difference between filename=${1:-/etc/hosts} and filename=/etc/hosts? [duplicate]

What is the difference between filename=${1:-/etc/hosts} and filename=/etc/hosts? For example: filename=/etc/hosts if [ -r "$filename" ] && [ -s "$filename" ]; then md5sum $filename ...
1
vote
1answer
56 views

Change a value in a config file, or add the setting if it doesn't exist?

When modifying config files from the command line, I often want to find the setting in the config file and modify that line if that setting exists. If that setting doesn't exist, I want to add it to ...
1
vote
3answers
169 views

How to read the file line by line and to print the previous line where the file contains a single token

For example my file is like: 59 6 18 2014 169 7 14 2 7671912 7849744 201 4 60 6 19 2014 170 5 49 2 7671912 7849744 201 5 61 6 20 2014 171 6 8 2 7671912 7849744 201 6 62 6 23 2014 174 5 3 2 7671912 ...
0
votes
2answers
31 views

Simple server that triggers script and responds

I need to have a very simple server running that can: Take rest call. It triggers a script when a call is made The script checks if database is running or not. If running then reply back to client ...
1
vote
1answer
23 views

How do I obtain the kill signal / message / reason within a script?

I am using the following trap: trap OnExit EXIT And in my OnExit function I would like to capture all the info I can on what happened so I can write it to a log file. Id like to know who, why, how, ...
2
votes
0answers
38 views

Remote script cleaning up

I run a remote script using ssh: local script: local_command ssh -p 222 user@server 'sh -s' < ./remote_run.sh remote script: some_command & sleep 10000 trap 'echo exiting' SIGINT SIGTERM ...
1
vote
1answer
34 views

Expect script: remove password on private key

I'm trying to remove the password on a private key. Doing it by hand is simple, I run this command and enter the password : openssl rsa <newkey.pem > newkey-no-password.pem I'm trying to do ...
2
votes
1answer
49 views

How to simulate user interaction when running another script

I am new to shell scripting. When I want to run a bunch of Linux commands I do fine, but how do I give user input when another script is called and asks for input while it runs. Here is the situation ...
0
votes
2answers
80 views

set variable options with dot

I'm trying to interface with a system not managed by me that is doing some Unix command scripts and command to easily execute a job. There is a variable substitution that doesn't work and I wonder if ...
3
votes
2answers
86 views

Variable assigned inside ssh command doesn't return proper value

I'm executing the below command in the ssh part of my script. The command is meant to cut the file size from ls option and storing it to a variable. Then print the variable: echo "Enter srouce file"; ...
2
votes
1answer
519 views

What is wrong with this code?

I have a script that goes like this: while : do Start_Time=$(date +"%s") MAIN PROGRAM GOES HERE (CROPPED TO SHORTEN THINGS) Run_Time=$(( $(date +"%s") - $Start_Time )) if [[ ...
2
votes
1answer
47 views

What does the period indicate when an environmental variable is set like “VARIABLE_NAME=.”

What does the period indicate when an environmental variable is set like VARIABLE_NAME=.
2
votes
4answers
123 views

How to initialize an array using awk and bash?

I am trying to store values of the first line of a text file into an array. Here is what I have so far: arr_values=() awk ' NR==1 { for (i=0; i<=NF; i++) ...
2
votes
4answers
242 views

Inserting a line in a file only if this line isn't yet part the file

Total newbie to shell scripting, I am searching to create a script to automatically apply some custom configuration to text based configuration files. In the present case, I am searching to add 2 ...
4
votes
2answers
103 views

Replace common values in two files according to first column

How do I replace common values in two files according to first column? I have file 1 (1.txt): CH063_01084 CH063_01083 CH063_13925 CH063_14473 and file 2 (2.txt): CH063_01083 FGSG_16349 4 ...