0
votes
1answer
16 views

Command in script fails with “not found” error, but runs fine on command line

I've created a minimal environment on my embedded ARM device consisting of just the Linux kernel, and with Busybox and a minimal filesystem in an initrd image. I have an inittab that runs ...
0
votes
1answer
24 views

sh + how to run command and set it into parameter ( VAL )

please take look on the following commands down, ( the shell is sh ) something not clearly for me when I run - eval echo \$arr$n , I get the value a as expected so why: VAL=eval echo \$arr$n , ...
1
vote
1answer
38 views

Finding subdirectories in linux

I am trying to search through all the subdirectories in the current directory for a directory named 'jdk1.7'. I have written a statement like find -type d -name 'jdk1*' But I am not getting any ...
1
vote
2answers
45 views

Not able to copy a file via script from local host to remote host

I am trying to write a script that can copy a file from local host to remote host. And then i want to execute that script from local host. But I am not able to copy. I googled and found the below ...
0
votes
1answer
53 views

Execute the shell command in subshell or in background?

Actually I mainly work with Ruby, but now I have created a bash script file. From this script file I am displaying the messages on the screen. Here is my scenario. I have used aosd_cat module for ...
0
votes
1answer
43 views

How do I call function after prompt for input in a Linux shell script?

The title says it all. After Im prompted, I want yes and no to respectively call a function. # Check to see if you ran this script before echo echo I need to know if this is your first time... while ...
0
votes
1answer
72 views

Shell script to check all the URLs from a file or list

I'm looking for a shell script to check a list of URLs and give output. For example: http://abc.com/index.php http://abc1.com/index.php I may place them in a separate file or inside the script. I ...
3
votes
3answers
104 views

How to format my text file for better appearance?

I want to format my text file for better appearance. So I want any command or any shell script which will format my file as per my expectation. Input File: Index Name City 1. Ravi Bhuva Ahmedabad 2. ...
-1
votes
1answer
47 views

Copy one directory to another while retaining its structure

Let's assume I have the following source directory: source/ subdir1/file1 subdir1/file2 subdir2/file3 subdir3/file4 And target directory: target subdir1/file5 subdir2/file6 ...
1
vote
1answer
25 views

Need help in the shell script - gunzip and file command

This is on Ubuntu 12.04. I have a custom webkit based application where "browser" saves bunch of cache files. When triaging the problems, I have to inspect the cache. The cache directory holds many ...
0
votes
2answers
34 views

Inserting a linebreak in lines starting with a pattern

I have a huge file that has the following format: #pair: 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 ...
1
vote
1answer
34 views

How do I identify shell script execution vs dot execution

I'm writing a bash script that needs to run on the current process for it to be useful. That is, I want to make sure that the script was invoked with source script.sh or . ./script.sh and not ...
1
vote
1answer
51 views

what does =~ in linux means used in if condition to compare values

Actually tomcat/conf/catalina.properties file contains line shared.loader=/usr/share/sfit/conf I mean value has some path. so using shell script we are updating shared.loader values in file. And also ...
3
votes
1answer
43 views

Greatest number in a column using shell script

I have a file that contains some data in column format, for example: 219m 219m 3.9g 3.9g 4.0g 4.0g 4.1g 4.1g 4.2g 4.2g 4.2g I want to compare the data and find the greatest value of these. Here g ...
0
votes
0answers
16 views

Scriptable resize (enlargement) of partition inside LV to end of LV?

I'm trying to automate some KVM installs, and I need to fit an existing image onto a newly created LV. The image is partitioned minimally, so I need a way to enlarge the first partition from the ...
1
vote
1answer
30 views

How to get the path of the newest file among the set of files which contains the same ID?

I want to write a script which will take the ID as an input from the user. Based on that input it will search the directories to match a file which contains the given id. Now, the directory has more ...
1
vote
1answer
70 views

Send me email everytime a certain file is accessed from my apache server

I want to have my server send me an email every time someone accesses a PDF file on my webserver. Perhaps: tail -f /var/log/apache.log | grep pdf > ??something?? How would I generate a new ...
3
votes
1answer
443 views

Linux command-line: Fastest way to disable internet (keeping LAN)?

Split question: this other one here is for Windows. Linux: Fastest way to disable internet (keeping LAN) from command line? I think the easiest way to deactivate internet (not LAN) in Linux is ...
5
votes
2answers
210 views

Bash: How to list n random number of files (not head or tail)

I have a large directory containing numerous files of similar kind. I have to send few random files for auditing. These files should not be from the top or bottom (eg. not in head or tail). This is ...
1
vote
3answers
1k views

Shell script bash: Moving file iterate based on month

I have very little knowledge about shell scripts, but unfortunately I have to write one. I want to ask about bash script iteration moving files, I need to move log files sorted by month which will be ...
3
votes
1answer
703 views

Bash script gives “command not found” error on if elif statements

Now before you flag this as a duplicate please understand i did search for this problem and i already tried all of the solutions to no effect. My script: #!/bin/bash echo "Enter the number 3" read ...
0
votes
0answers
43 views

Implement Roll-backing in bash script

I have implemented an Ubuntu package in which bash scripts are using. I followed these for making packages in Ubuntu. ...
2
votes
4answers
127 views

Add a display to let user wait in bash

I am looking for a pretty stupid piece of code for bash that will show a kind of "please wait" rolling display, with the characters : - \ | / The first problem is that I don't know the name of this ...
1
vote
3answers
48 views

changing order of files

I have a series of files named in alphabetical order (xaa.tif to xdg.tif). I need to reverse the order of the filenames so that the last file is processed first in a script. I would like to rename ...
0
votes
5answers
407 views

How to test if a variable is equal to a number in shell

I have this shell script that isn't working. Input: Server_Name=1 if [ $Server_Name=1 ]; then echo Server Name is 1 else echo Server Name is not 1 fi Output: Server Name is 1 But, if i ...
1
vote
1answer
69 views

How do I write a conditional assignment in a Linux script?

I need to create a formula in a Linux shell script. If this was DOS, I'd (probably) be fine, but I've made the change and need to learn....! D1 = a 5-digit number between 40500 and 49500 (this is ...
1
vote
2answers
213 views

Filling up the hard drive until certain amount of space is left?

I'm doing some testing of a product on Apple and Android devices. I'd like a script that will fill up the devices hard drive until 100KB space is left on the drive it's runs against to. Also in linux ...
0
votes
1answer
45 views

Linux flow control exit to terminal on failure

I have a query with flow control. I want to exit the script to terminal when the message is: HOSTNAME NOT ADDED IN /tmp/hosts EXITING, which is a failure message. if grep -o 'abcdefgh01.was.db.dcbc' ...
1
vote
1answer
138 views

error when using while loop in bash script

I am getting an error 2: [: missing ] when using the following while loop: #!/bin/sh while ["$INPUT_STRING" != "bye"] do echo "please type something (bye quits) " read INPUT_STRING echo "you ...
1
vote
1answer
213 views

Bash Script for Rar command

I need a script to rar my files usage will be like this r1 archivename fileordirtocompress with following attributes rar a -m0 -v1024000 -r How whould this bash script look like? #!/bin/bash ...
1
vote
1answer
259 views

How can I save some terminal commands as a file and run them?

I am using OpenSuSe 12.3 I want to create a link on my desktop for some specific terminal commands. The background is that I do some backup via rsync and don't want to type the commands every time. ...
0
votes
4answers
875 views

Listing all words in a text file and finding the most frequent word

I have a file which contains lines. How do I write a script that will find and print out every word in the file, one word per line. Then find and print out the most occurring word (case sensitive) ...
0
votes
2answers
91 views

Rearrange content of a file

I'd like to rearrange the content of a file on a per line basis (see below), ideally without using Perl or Python (I'm not allowed to... Don't ask.) The input file contains unordered header lines and ...
0
votes
2answers
38 views

Where to place an executable Perl script?

I'm now planning a solution that has to call a script that's running on a Linux \UNIX host. I'd prefer to place that script in a folder that exists in all kinds of Linux and UNIX. This helps me to ...
1
vote
1answer
40 views

Filtering out incomplete log entries

I'm trying to get some garbage collection logs into Splunk. However, when java starts garbage collection, it starts the log entry, then when it's done it puts in the end of the entry. Splunk treats ...
1
vote
1answer
291 views

Can't get computer to reboot via script

I need to reboot an embedded system via a local network webpage (a CGI script). I have the page built, and it calls a script on the station (which is the (apache) host of the webpage). This script is ...
0
votes
1answer
81 views

New process being created while checking with 'if' in bash

ps -ef | while read line; do for i in $line; do if [ $i = 'bash' ]; then echo $line; fi; done; done; unset i; The command runs properly displaying the Bash ...
0
votes
2answers
86 views

Instructions embedded in Bash script?

Is there a way to make a bash script require a set of parameters when it's loaded, and if not, it will automatically spit out an echo to the screen giving instructions? Looking at this example of a ...
1
vote
1answer
339 views

Entering into multiple directories in Unix and deleting a particular file

I have a list of directories that I want to go into and delete particular files. For example, the directory names I have are as below: 091513 090213 082612 071611 020908 011009 ... 062308 Each of ...
1
vote
1answer
393 views

How do I create a one time use startup script on Linux - Centos 6.x

I want to set a script that will only run one time on a Centos 6.x box and then never run again, since it's going to set some system options based on hardware and then it's all set.
0
votes
1answer
619 views

Execute a jar with double click in linux

What I'm trying to achieve is to run a java program on any Linux system (Ubuntu, Fedora, etc... covering as much as possible) by simply double clicking a file-like I would on Windows. I have created a ...
2
votes
1answer
287 views

Running commands and shell scripts in Ubuntu

I'm trying to run a shell script in Ubuntu to flash my Firefox OS phone. I've downloaded and unzipped the new version. I've launched the shell and navigated to the directory where the .sh file is. ...
7
votes
1answer
1k views

Shell script to find all types of files in a directory with their count

I want to write a shell script or alias to find the number of different types of files in a directory. For example, sample output of script should be: *.h 20 *.c 40 *.cpp 10 Makefile 3
2
votes
2answers
99 views

How can I get the shell-script-mode in Emacs to intepret #PBS -S /bin/bash to be a bash shell code?

I am using Emacs on a LINUX system that uses Portable Batch System (PBS) for controlling the use of resources. The PBS scripts require "#PBS -S /bin/..." as the first line in the script to declare the ...
1
vote
1answer
267 views

Grab single image from website on a regular schedule

I want to grab the same image (from a website) every x minutes to eventually make a timelapse video. My issues are: setting up the schedule to grab the image and saving the image with the ...
0
votes
1answer
471 views

How to create Bash script when user root logout sending email alert include history

I found the following command: history | tail -20 | mail -s "log `hostname` pada `date`" mailid[at]corporate.com I want to combine it with an automatic logout script: The system should send an ...
1
vote
1answer
147 views

xargs in shell script

I want to group jpeg images by odd number and even number. So I did like following: $ mkdir odd $ mkdir even $ find . -regextype posix-egrep -regex ".*[13579].jpg$" -print0 | xargs -i -0 mv {} odd/ $ ...
1
vote
3answers
53 views

Write a command to switch to specific directories

I have some directories that I have to go to a lot more often than others, like for music, work, programming, etc. So I want to have exclusive commands, say "gotomusic" or "gotodropbox" to go to these ...
2
votes
1answer
133 views

What this command :(){ :|: & };: does? [duplicate]

What does this shell command do in Linux :(){ :|: & };: How can it be used in Denial of Service attacks?
0
votes
2answers
73 views

How do I parse metacharacters for function input in bash?

I wrote a function in bash which gets * as input and therefore sould list all files in that particualar dircectory. but doesn't. Here is what i wrote: # a function that mass deletes files in a ...