Programming :: Running Script Bash To Fill Files?

Mar 21, 2010

I have around 600 empty text files that I need to add the name of this file as part of the data, I meanfiles from "file1.txt to "file599.txt, all of them empty, and I need to get the name inside the file, so, when I open the file show the name as part the data "file1".these files were created on my web site, I am thinking in a small script in bash

View 5 Replies


ADVERTISEMENT

Programming :: Sed Running Under Bash - Getting Error

Jul 18, 2010

~$ sed s/^bb/bbbbbb/ foo1.txt
~$ sed: -e expression #1, char 3: unterminated s command
~$
Where 'b' stands for space. What is the error here? Sed is running under bash.

View 6 Replies View Related

Programming :: BASH - Can't Check If XScreenSaver Is Running

Feb 26, 2011

I'm having trouble trying to make a script. What I want to do is check if xScreenSaver is running in my user account. If not, run it. If it's running, kill it.

So this is the script I've made:

Code:

The problem is that I've echoed the output of $(pgrep -u $(whoami) xscreensaver) and it always seems to add 4 numbers to the pid, even if the pid doesn't exist. What do I mean by "doesn't exist"? That no xscreensaver is running in my user, and if I run pgrep -u $(whoami) xscreensaver in bash, I get not output, but if I run the command though the script, I get (for instance) 4050. If I run it again, I get 4054, and again 4058... etc. What the hell is going on with that?

View 5 Replies View Related

Programming :: Change Running Path In Bash

Feb 5, 2010

We have a custom app that runs on boot on some older hardware running DSL linux, and their startup manager was quite simple. We purchased some newer Asus eeebox's which run xandros and things are quite stable and run nice with 1 exception.The application only runs from the root (/) location. This box auto logs in as 'user' and there is a /home/user/.kde/Autostart folder where you can stick scripts to run at boot. So I have a start.sh script, and with little bash programming tried things such as;
sudo cd /
sudo /startapp.pl

but the errors start spewing with the basic;can't find data/xyz as it's looking in the local.I thought there was a basic cwd (change working directory) but everything I try just forces the run from that location.Any ideas or suggestions are appreciated, but things like can you change the code, etc. can't be done, so it must be a programming thing. The only other thought I had but not sure, can you do a cronjob with @boot or something, that when the box starts, it can run this job as root and fire off?

View 3 Replies View Related

Programming :: Making Sure Script Is Running In Bash?

Feb 15, 2011

is this a good way of doing it? Shall I use & when starting the new process? Itested in bash and dash.

testbash=$(ps -e | grep $$ | grep bash)
if [ 0 = ${#testbash} ]; then
echo "new process"

[code]...

View 11 Replies View Related

Programming :: Running Bash Script In New Screen?

Feb 16, 2011

I have a bash script that I want to be running on a "clean" screen, but when the script finishes/exits I want to see what was previously on the screen. Any thoughts? The "Clear" command does not enable me to get the information back, and the "Screen" Command runs the program in the original window, so you see nothing until the new screen is exited.

View 4 Replies View Related

Programming :: Running Bash Script Using Java?

Aug 18, 2010

how can i run a bash script script by using java in rhel5... then please reply....i have vary good project in my mind.....

View 2 Replies View Related

Debian Programming :: Running Programs In Parallel In Bash

Jul 22, 2014

I am trying to replicate what is happening on this page under the tcsh shell, but using the bash shell found in Wheezy. Here is the page I am referring to:[URL] The command I am trying to replicate is on page 6 under figure 2.4. The command is "prompt> ./mem &; ./mem &".

I would like to run the same program twice, concurrently, but do not know how. Note that I am not trying to use a bash script, but rather by simply using syntax on the command line.

View 4 Replies View Related

Programming :: Find Out If X11 Is Running From Within Perl OR Bash Script?

Mar 17, 2010

I am writing a script based image manipulator but i need to know if X is running so i can tell if i use CACAVIEW to imagemagick DISPLAY command.

View 14 Replies View Related

Programming :: Simple Bash Script Is Not Running All Of The Commands?

Jun 14, 2010

I am running a simple script that I copied from slug.ceca.utc.edu/docs/2009-3-26-linux-server-health.pdf and edited with the names and paths of my own servers. I don't know much about scripting (re: nothing) but I wanted to try and be efficient in my new role as a Linux Sys Admin. The script was saved to root's home directory and runs as part of root's crontab once a week. The script runs with no problem, but it doesn't actually seem to run all of the commands contained within. It skips some in the middle and the end and I don't know why. The script itself is this:

Code:
#!/in/bash
uname -a > /tmp/server.txt

[code]...

View 5 Replies View Related

Programming :: Bash Programming - Rename Files In A Loop?

Mar 31, 2011

I need to rename the resulted searched files from a loopI have the following code:

find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done

basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell

View 10 Replies View Related

Programming :: Catch User Input While The Bash Script Is Running?

Oct 30, 2010

How do you catch user input while the script is running? Or, how would you make two scripts run at the same time, but use input from one script to the other? The program I'm trying to make, echos text on the screen continuously, but while thats happening, I want the user to be able to input something, so the program can detect the input and display something else. So I thought maybe I could make two scripts run to do each task.

View 5 Replies View Related

Programming :: Fill A File With N Bytes Of A Given Value?

Dec 17, 2008

How do i fill a file with <n> bytes at a given value ,for example 3?

View 3 Replies View Related

Programming :: Print A Line Of Fill Character In C?

May 15, 2010

As you know, in C++ you can use setfill(char c); and setwidth( int length) to fill a line of a character.
It's line making a line of a character for output

Code:
NAME DEPARTMENT LOCATION
==========================================
Pete R&D Chicago
...
==========================================
As you see, a line of a '=' character drawn to output.

I'm wondering, how can I draw this line in C using printf() to format?
( no loop or repetiton )

View 8 Replies View Related

Programming :: List Files In Bash + Add Url Before Them?

Dec 8, 2010

I am an uploader to a various hosts, so this tiny script me a lot. I make a rar archive and split files with 100mb. I could get 3-4 or even 76 parts of rar files and it would take me some time to paste all these urls to remote upload function of filehosting sites. For example:

Code:

server:/home/cober/downloads/teevee# ls -al
total 358784
drwxrwxrwx 2 root root 4096 Dec 8 19:38 .

[code]....

View 1 Replies View Related

Programming :: Bash Script To Copy Files?

Jul 13, 2011

I have a lot of filenames (strings) following the same convention

m02_+1+7_London_0000$01.cfg
m02_+1+8_London_0000$01.cfg
m02_+1+8_London_0000$01.cfg

[code].....

What I want to do is to create a script that will interpret the following string and save into variables part of its name

m02_+1+7_London_0000$01.cfg as
------X-Y--City---------
X=1
Y=7
City=London

[code]....

then I want to copy the files that go all the files with the same City and X and Y to the same subfolder City/MX.Y I will need some help start doing that. And I think the first would be to get part of the filenames strings into variables.

View 3 Replies View Related

Programming :: Bash Find Files On Time Help?

Mar 11, 2011

I am trying to find a nightly backup if it was successfully copied over, rename it and curl, but it's always passing the check even if the file is older than specified. From the command line it does as it should. Example is here;

Code:
find /backup -type f -mmin +4440 -exec echo "found" {} ;
- nothing returned (good). Then I change the time

[code].....

View 4 Replies View Related

Programming :: Bash Function For Searching Files ?

Jun 15, 2011

I'm making a small script for searching and doing some operations with photos, but I'm kinda stuck on this little function:

Code:

function findallformat {
prefix=""
if [ $1 = -pre ] then

[code]....

That function should find for every file with a certain type; and you can specify a prefix using a "-pre" followed by the prefix that you want to search. The format should be "stackable", so you can use as many types that you want, without repeating the same function on the code.

Example: findallformat -pre IMG_ .JPG .CR2 #That should search files that start with "IMG_" and finishes with .JPG and .CR2. My problem it's that, when I try to use it on the script, it says "bash: syntax error near `token' unexpected `}'"

View 4 Replies View Related

Programming :: Catch Some Outputs In Two Different Log Files In Bash?

Jan 26, 2009

I want to catch some outputs in two different log files in bash, file simple.log and all.log So far, the script is started like this:

Code:

xterm -e "(./myscript.sh | tee -a simple.log) >& all.log"

What I want is:

- In simple.log, I want all the stdout but WITHOUT errors.

- In all.log I want BOTH stdout and stderr.

So all is ok, and the output becomes:

all.log

Code:

starting copying files
mv: cannot move ... : permission denied
copying completed
simple log

Code:

starting copying files
copying completed

But, in the new xterm, I'm loosing stdout. There is no output.How can I have the files logged as they are but also have the stdout in the xterm.

View 6 Replies View Related

Programming :: Bash - Renaming Files Won't Work

Apr 1, 2010

I'm trying to rename a lot of files getting rid of the space on the names. For that purpose I wrote this very simple bash script, but for some reason is not working.

Code:
for i in "$(ls)"
do
j=$(echo "$i" | sed 's/ /_/g')
mv "$i" "$j"

done But what I get in return for each line is just one long file name with all the file names concatenated. I've tried with echo -e "$i" as well with no results. This has to be something really simple that I'm missing but I just can't see it.

View 11 Replies View Related

Programming :: Reading Files In A Directory Using Bash?

Nov 6, 2010

I am trying to write a simple script to list all the files in a directory. The script I wrote was as below where the pdb_files is a directory and all the files which I want to list are in that folder.

Code:
files=`ls -F pdb_files/*THERMO*`
for inFiles in $files
do
echo $inFiles

[Code]....

View 5 Replies View Related

Programming :: Double Pointers / Matrix GCC (fill It One Column With Zeros And The Other With Ones)

May 26, 2011

I have a 10x2 matrix, I create said matrix and fill it one column with zeros and the other with ones, now when I print the matrix I get this:

column 1:
0,0,0,0,0,0,0,0,1,1
column 2:
1,1,1,1,1,1,1,1,1,1

The first two rows of the second column are being replaced into the last two rows of the first column, now I even checked in visual studio and it works fine there. A friend tried my code and he gets it even worse:
column 1:

0,0,0,0,1,1,1,1,1,1
column 2:
1,1,1,1,1,1,1,1,1,1

As far as I've seen it must be a problem with GCC, unfortunately I need to have this up and running in GCC no matter what.

[Code].....

View 6 Replies View Related

Programming :: Bash Script - Make Sure All Files Have Certain Permissions

Jan 14, 2011

How can I iterate over all the files in the current directory to check for certain permissions? This is what I have:

Code: #!/bin/bash
for file in *.tar.gz
do if [ -r "$file" ]
then echo "$file is readable"
else echo "$file is NOT readable"
fi done

But this only checks that the current user has read permissions for each file. I want to check that the group "others" has read permissions for each file. How can I do this? Is there a built in function to check if a file has read permissions for the "others" group? Otherwise, I thought I might be able to use this:
Code: $ stat --format=%a file
744 And parse the output "744" and make sure the 3rd number is between 4 and 7 (since the octals 4-7 have read permissions for others).

View 2 Replies View Related

General :: Filter Script Files In Bash Programming?

Feb 10, 2010

I'm building my first BASH programs and I have a hard time. I can't do a search in a folder and filter only script files without extension, the problem is to differentiate the script files from the others. I tried with ls I tried with find and i don't find a way to make it work.

View 8 Replies View Related

Programming :: BASH : Using A Loop To Download A Series Of Files?

Feb 2, 2010

Never mind, I figured it out myself. Firstly, the old version of BASH I'm using doesn't support

Code:

for i in {1..27}

So I had to use

Code:

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

Secondly, it was simply

Code:

#!/bin/bash
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
do

[code]....

View 2 Replies View Related

Programming :: Bash Script That Will Operate On All Files In A Directory?

Jul 22, 2011

I have about 50 files that the script will operate on, they are all located in the same directory.I need a bash script that will operate on all files in a directory. The script needs to add two lines to the beginning of each file based on the file name, and one line to the end of the file.A file named myfile.h should add these two lines to beginning of the file:

Code:
#ifndef MYFILE_H
#define MYFILE_H

[code]....

View 5 Replies View Related

Programming :: Bash Script To Check How Many Files In Directory?

Jan 31, 2009

i was wondering if there's a bash script to check the amount of files in a directory with an IF statement..

View 8 Replies View Related

Programming :: Bash Scripting - Output As Multiple Files?

Jan 26, 2011

I have wrote a 1 line command that parses a file, locates the IP Address in the file and then trims the output the way I want it, and then sorts numerically and by uniqueness and then >> appends to output.txt

I can get all the IP's into 1 file "output.txt", but what I am really looking for is some type of way to create a text file, for each IP it finds labeled xxx.xxx.xxx.xxx.txt and also put that ip address into that file..

xxx.xxx.xxx.xxx = the ip address it finds

View 14 Replies View Related

Programming :: Can't Remove Temporary Files Using Bash Script?

Nov 9, 2010

However, the ffmpeg command generates a temporary file blahblah.mpg.tmp of about 1GB per hour of transcoded video.My issue is that I can't seem to delete these files automatically from any bash script.Now from the command line, I can cd to the directory and just rm -f *.tmp and they get deleted. However, from my script, that same command doesn't remove those files. I thought maybe the file was in use, so I put a sleep command in for like an hour before the delete happens, but it still fails. I also put rm -f /mnt/mythtv/*.tmp in a root cronjob and it still doesn't delete the files.

If I just rm *.tmp I do get a prompt about "Are you sure you want to delete this write protected file?". But the -f switch seems to work fine as a normal user from the command line and just delete them.Does anyone have an idea how to troubleshoot this problem? The particular filesystem that the tmp files get generated on is on it's own xfs partition mounted as /mnt/mythtv.

View 8 Replies View Related

Programming :: Copy Only Newer Files With A Bash Script?

Mar 29, 2010

I have to copy some log files with a cron job; I'd like to copy only the newer files added because I run the script with a weekly cron. all the log files are named like "10-03-29.CVS" and reside in a dir. When I copy I'd like to copy only the files not already copied with the last cron job.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved