3
votes
2answers
148 views

Shell script wait for background command

I am writing a script, but there is something I need that I can't find a way to do it... I need to make a command in background "command1 &" and then somewhere in the script I need to wait for it ...
2
votes
7answers
70 views

Sort the files in the directory recursively based on last modified date

Sort the files in the directory recursively based on last modified date I have modified a lot of files in my directory want to know what are those files by sorting them by the last modified date ...
4
votes
3answers
193 views

Execute a command on user logon

In Linux desktop system, I want to execute a command when the user logs in. After reading some other posts, I tried to insert the command in ~/.bashrc but unsuccessfully. Moreover, the system uses a ...
1
vote
1answer
44 views

how to check if mysql table is used or an application accesses the table in shell script?

A shell script is doing dump for a mysql table, but before dumping the table I want to check if this table is used by any other application. If so, I want to wait and enter in a loop until the ...
1
vote
3answers
124 views

Delete files with same name at the end of the file

Delete files with same name at the end of the file i have a lot of files in my folder and sub directories like ajax_hostel_room_master.php.php class_hostel_registration.php.php ...
5
votes
1answer
167 views

When is it important to write portable scripts?

Most code I write is in PHP. I have recently started learning shell scripting. Most of the resources and tutorials that I've come across are specific to Bash. Some warn about bashisms and some don't. ...
1
vote
0answers
34 views

Logging into multiple SSH servers as root and create an user with same power as root does [closed]

I need a script from which I can log into multiple servers as root (but not all root passwords are same;there are 3-4 different root passwords) and make a superuser (user with same access as root) but ...
1
vote
1answer
53 views

How do I rename lots of files on a directory without changing their extensions? [duplicate]

I have a problem! I have a bunch of image files with extensions. Jpg and. Png. I wrote a script that renames the files, changing their names in a pattern followed by a number like this: ... ...
2
votes
3answers
93 views

creation of user add

I'm having more then 59 servers I need to create a script for user add. purpose: if I'm creating a user in one server it will be reflected on all 59 servers. How can I accomplish this?
3
votes
3answers
340 views

if/then/else man page

I would like to know if there is any man page documenting the construction of the most basic script commands like if/then/else, while, for each, and all the relative switches, like -eq, -e, -ge, and ...
-2
votes
2answers
105 views

how to execute a python program in a shell script

I have a python program in that I wrote some python code (disk.py). I executed this program using the command python disk.py in a terminal, it worked. Now I want to execute it using a shell script.
1
vote
3answers
134 views

What does “FILENAME=$(echo $INFILE | grep -oE ”[^/]+$“) ” mean?

FILENAME=$(echo /root/Source/code/script.sh | grep -oE "[^/]+$") I know that it would give me the file name from the file path here as script.sh. But can some one please explain me this?
0
votes
2answers
88 views

Using grep to find first two numbers of IP addresses?

I'm trying to figure out how to use grep to pull out only the first two numbers of an IP address in a list. I've got a routine that is isolating the log entires (from Exim) that I need, now I just ...
3
votes
3answers
124 views

Shell Script to move folders containing a specific word

I'm searching for an simple shell script to mv all folders in /var/www/uploads/ that containing Math or Physics in the name to /mnt/Backup/. I've never done something like that before, due to the ...
1
vote
1answer
29 views

Pressing tab after sourcing script file prints script related output

I have a script file in a directory. Its contents are as follows : #!/bin/bash ...
1
vote
2answers
41 views

Make Trickle get the correct $PATH

Trickle is a bandwidth limiting program. I have the following script for trickle. #!/bin/bash echo $PATH trickle -s -t 3 -u 200 -d 200 "$@" I have a script in ~/bin/ that want to run the script ...
0
votes
1answer
68 views

Can I use an if statement to detect if bash and dash are being run interactively? [duplicate]

After looking around for a while I've found several good pages describing how to check and see if a bash script is running interactively and there seem to be several methods, but one of them that I ...
2
votes
2answers
69 views

How to split files with common prefix in bash

I have a directory with many files with common prefix, like gsc*_other.foo, where * is a character that goes from 0 to 9 or a/b (where a stands for 10 and b for 11). My goal is to create text files ...
0
votes
1answer
157 views

How to execute Netscaler commands through a remote machine via SSH connection

I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection. Now the Problem is, Manually we are able to enter & execute commands on ...
5
votes
3answers
339 views

Using notify-send with cron

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron. I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without ...
4
votes
1answer
99 views

Bash is automatically reloading (injecting) updates into a running script upon saving it: Why? Any practical use?

I was writing a bash script, and happened to updated the code (saved the script file to disk) while the script was waiting for some input in a while loop. After I returned to the terminal and ...
0
votes
3answers
101 views

How to compact a chmod UNIX command

Is there anyway to compact the follow UNIX command: chmod 755 scriptA.ksh | chmod 755 scriptB.ksh | chmod 755 scriptC.ksh | chmod 755 scriptD.ksh The above command makes every KornShell (ksh) ...
1
vote
1answer
161 views

Linux - Sending a command to a screen through a shell script? [duplicate]

I'm trying to figure out how to make a script that will be able to send commands to a screen that will execute within whatever the screen is doing. Is this possible, and if so, how is it done? I've ...
1
vote
1answer
56 views

Linux - How to open a console and display command results on startup?

I have a Linux server with a screen always displaying the end of a very usefull file. How could I automatically enter a shell and display the end of this file when the server starts? I'd like to do ...
1
vote
2answers
146 views

How can I make awk on Busybox treat the entire input with NULL character in between as a single record?

I wrote a base64 encode script for my Busybox system. #!/bin/sh base64encode() { /usr/bin/awk -- ' function asc(char,l_found) { l_found=0; for (i=0;i<=255;i++){ if ...
1
vote
1answer
76 views

How to script this task?

First of all, I can make basic use of the linux command line, but have slim to none experience with shell scripting. What I want to do: I have a router running OpenWRT, a destop pc and an Android ...
2
votes
3answers
84 views

What is the language that appears on the first line of a script? [duplicate]

Bash scripts start with the following line #!/bin/bash # Rest of script below ... In bash the # character is the start of a comment, but #!/bin/bash is definitely not a comment, therefore it isn't ...
1
vote
2answers
50 views

copy a section of data from stdin [closed]

I am running a script that takes its input from stdin. This input can end up being very large so I want to extract the part I'm interested in to a temp file. The first line contains "[cics]" and I ...
3
votes
2answers
33 views

Overriding amended time stamps

I need to make it so the files in current directory get amended with a timestamp. It works fine for the first time, but once I run it again it adds another timestamp to the file. I need a way to ...
2
votes
1answer
45 views

How do I drop to a shell after exiting a command I started by scripting tmux?

I'm following this tutorial for scripting the creation of tmux windows. tmux new-window t $SESSION:0 -k -n MAIN 'cd ~/main/ && perl -Ilib myapp' sometimes I kill myapp after I've started ...
2
votes
2answers
223 views

How to copy multiple files but keep their extensions the same?

I am looping through a number of files, and $file represents the current file. How can I make copies or renames and keep the extension the same for this current file? e.g. if $file = x.jpg How to ...
1
vote
3answers
99 views

How to add Multiple Searches in AWK command

Im trying to search for the files Created in June,July and August months. I used this method ls -lrth|awk '/[Jun][Jul][Aug]/ {print}' but it ain't working. Please help me correct the syntax.
4
votes
3answers
750 views

Summing up an array inside of awk?

I have the following piece of code: sum1= sum2= declare -a a echo $temp | awk '{split($0,a,","); name=a[1] ; for(i=2;i<=4;i++) sum1+=a[i] ; for(i=5;i<=7;i++) sum2+=a[i] }' This code is ...
0
votes
1answer
234 views

How to run a shell command in a server?

I am fairly familiar with computers and web stuff but this is a bit out of my comfort zone. I have a shell script (.sh file) I want to run in a Linux server I have one site hosted (the script is a ...
5
votes
2answers
203 views

Launching an external script with source command

I've been learning shell scripting, by reading good tutorials and reading scripts. I was reading this minecraft init script, and these first lines hit me: if [ -L $0 ] then source `readlink -e ...
1
vote
1answer
242 views

Press a html button via shell script?

i am currently trying to write a script to change some parameters on a webpage via a shell script. I can change the values in the textboxes without any problems, but i can't seem to figure out how i ...
4
votes
4answers
669 views

Capture output of a bash command, parse it and store into different bash variables

Explanation: I have a small bash script which simply runs any Linux command (e.g. say ifconfig) The typical output of ifconfig is something like this: eth0 Link encap:Ethernet HWaddr ...
6
votes
4answers
537 views

Bash script to rename files from a text file source

I'm fairly new to bash; I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as ...
1
vote
3answers
90 views

Taking Backup of files of particular limit in unix

Here is the scenario, I have 1000 files in a folder each ~3 MB. I want to zip all files into 50MB each zip and remove the original files. NOTE: 50MB may contain 20 files or 10 files but that zip ...
1
vote
0answers
160 views

gnome-terminal cmd leaving processes open after closing parent window

The following simple command should demonstrate my issue: gnome-terminal --tab -t "Tab 1" -e "/bin/bash" --tab -t "Tab 2" -e "/bin/bash" This should open a new window with two tabs and an active ...
2
votes
2answers
136 views

Looping over a folder enter anyways the loop

When looping on a folder through a for f in $path I am experiencing an unexpected behaviour, i.e. the loops is entered anyway even if no file match the wildcard. I am using cygwin and this is my ...
0
votes
3answers
144 views

Renaming all files in a directory while keeping the same initial part of the name [duplicate]

I have a directory full of files. I want to rename all the files that match *.py to -backup.py. How do I do that. I know I can use for i in *.py, but from there I'm not sure how to keep the ...
0
votes
1answer
146 views

when to use double quotes with a variable in shell script? [duplicate]

I am in a confusion with what is meant by the double quotes referring to a variable. For example following two scripts gives the same output. What is really meant by the double quotes? Script1 ...
0
votes
1answer
146 views

Bash script installing within multiple directories [closed]

I am attempting to write a bash script that will install rbenv from beginning to end. I am on a Mac for interest sake. But there are some things that are not working mainly i am changing the ...
1
vote
3answers
1k views

sed - how to replace a single quote?

This works fine: sed -i 's# @driver.find_element(:xpath, "//a\[contains(@href,##' temp_spec.rb against a source of @driver.find_element(:xpath, "//a[contains(@href,'change_district')]").click ...
1
vote
2answers
141 views

Direct recursive shell script output to each subdirectory, not parent directory

I'm processing a batch of subjects data recursively, calling the script within the parent directory. For example, I have the parent directory: /home/subjects and the subdirectories which contain ...
2
votes
1answer
138 views

Invoking a script with ld-linux.so?

I just downloaded a tar file that is supposed to include everything required to run a program that we can call some_binary. I extracted it's contents, and I see the following: A binary (let's call ...
4
votes
3answers
114 views

CD into directory from HISTORY in a bash script or alias e.g. $(!!)

I often want to change into the directory of a file on my file system, but I'm not sure where the file is. I search for it like so: find -type f -name "myfile.txt" Lets say for the sake of ...
4
votes
1answer
1k views

Increase %e precision with /usr/bin/time shell command

When I run the time command in shell time ./myapp I get an output like the following: real 0m0.668s user 0m0.112s sys 0m0.028s However,when I run the command \time -f %e ./myapp I lose ...
1
vote
1answer
581 views

How to match 2 large file and print the difference in shell script

I have 2 files. File1 has 400k numerical records. e.g: 1 2 3 4 5 6 .. and so on File 2 also has 420k numerical records. e.g: 1 2 3 4 6 .. and so on Both these file are in unsorted manner. I want ...