Fedora :: Write A Shell Script That Will Look At Each File?

Jul 23, 2010

I have a number of text files throughout my /home/pjs/Documents directory tree that have execute permissions set. Almost all of my file names have spaces in them. I am trying to write a shell script that will look at each file in my Documents directory, find the ones that have execute permissions set, and run the command chmod 644. Of course, I don't want the command run on the directories.

The following script *doesn't work*, but might serve to illustrate what I am trying to do:

#!/bin/bash
for x in "$(ls -R)" do
if [ -f "$x" ] && [ -x $x ]; then
chmod 644 "$x"
fi
done

I want each file and directory name to be placed, one by one, in the variable $x, and then tested with the "if" conditionals.

The first problem seems to be that, although the command "ls -R" does produce a complete list of the files and directories I need, they are not placed, one by one, in the variable x like I want them to be.

Also, I think I should use the shift command so that the option -R doesn't get included as one of the values of the variable $x, but I can't figure out where to put it.

View 14 Replies


ADVERTISEMENT

Programming :: Write A Shell Script Which Edits A Config File ?

Mar 1, 2011

Write some simple script?

Heres what Im trying to do:

-Qjackctl has a config file which is modified each time QjackCtl is shut down. This means that whatever preset is in use when QjackCtl closes is written into the QjackCtl config file as the DEFAULT PRESET, for the next time QjackCtl starts (or at least this is how I understand it).

-I want to edit a specific line in the QjackCtl.config file, which specifies the DEFAULT PRESET. Obviously its easy to do manually, but I want to do it using a shell script which runs automatically on StartUp so that QjackCtl starts every time with the same DEFAULT PRESET, NOT the last one used.

-Unfortunately Im not at my Linux system right now (which is KXStudio/Kubuntu), but I believe the QjackCtl.config line looks something like this: DEF_PRESET=alsa (where alsa is the name of the preset)

PRESET1=alsa
PRESET2=firewire

I want a shell script which changes the line DEF_PRESET=alsa to DEF_PRESET=alsa, even when it may currently exist as DEF_PRESET=firewire due to occasions when firewire was the active preset when Qjackctl was last closed. I notice that the application in KDE that enables the user to set which applications open automatically on StartUp also allows the user to select shell scripts.

Ive done some research, as a beginner, and Im led to believe I might need to use AWK and/or CHMOD. I could have a go at writing a shell script but Im always wary about experimenting with StartUp scripts/operations because obviously if I get it wrong and make my system unusable, then because its going to run first thing on each boot, Id have great difficulty disabling it.

View 3 Replies View Related

Programming :: Write A Shell Script Which Will Check A File Name In A Dir And Copy It?

Apr 2, 2010

I am a novice to the shell script. In my system from db server the log files are enerating with the name log1.txt,log2.txt..... It is capable of keeping 10 files at a time in dir called /db/sis/log1.txt. I want to copy the log1.txt to another directory when ever it generating by attaching the time stamp to it for the back-up purpose. this files will be there for a period of 24 hours. after that the back-up dir should be cleared and it start copying again the fresh file from the same dir.

View 3 Replies View Related

Programming :: Find / Write A Shell Script That Will Go Through A File Organized?

Jul 3, 2009

I am trying to find / write a shell script that will go through a file organized like this (but with thousands of lines)...

93,5.00,"contig00002",169,83,"jgi|Brafl1|100379|fgenesh2_pg.scaffold_359000019"
579,1.00,"contig00003",3,380,"jgi|Brafl1|114745|estExt_fgenesh2_pm.C_1200006"
450,5.00,"contig00007",2,352,"jgi|Brafl1|274326|estExt_GenewiseH_1.C_8420008"

...and check the region of each line between the second and third pipes (the 6-digit numbers) against the values in the first column of a separate text file in CSV format like this...

274326,"Wnt family of developmental regulators"
114745,"FOG: Hormone receptors"
100379,"Transcription factor tinman/NKX2-3, contains HOX domain"

...and when they match, replace the value to the right of the third pipe (e.g., fgenesh2_pg.sca...) with the value in the second column in the CSV file associated with that number.

View 4 Replies View Related

General :: Write Expdp Output In A Text File Using A Shell Script ?

Feb 7, 2011

I want to write expdp output in a text file using a shell script

If i write like below:

It will write whatever is there in log file to text file

But, sometimes export fails with out start taking export (without generating log file) because of job already exists error. such times, we dont know about that error until we check manually... so i wrote like below:

But still it is not writing anything in to text file using above stmt...

View 1 Replies View Related

General :: Write Shell Script To Check The Modified Date Of A File ?

Jun 17, 2011

I have two linux servers, they are backup together.

1. Server 1 have 3 files with name: file1, file2, file3 in the path: /etc/sysconfig/network-script/.

2. Server 2 have 3 files with name and path are the same as server 1.

- How to make a script to copy 3 files at server1 to overwrite on server2. But before overwrite, this script will check and compare the last modified date of these 3 files(on server1 and server2). if the modified date of file1, file2 or file3 on server1 is newer than 3 files on server2 then overwrite process will do, if not, will do nothing.

- see my script as below: it works find now but just overwrite. not check last modified date.

View 1 Replies View Related

Ubuntu Servers :: Write A Shell Script In Order To Automate The Process Of Uploading A File?

May 21, 2010

I am trying to write a shell script in order to automate the process of uploading a file onto an FTP server using the built in FTP commands in ubuntu server (lucid). In order to connect I can use the following:

Code:

ftp wsbeorchids.org.uk
Name (wsbeorchids.org.uk:danielgroves): USERNAME
Password: PASSWORD

In need to pass my username and password in when prompted the prompts. How should I go about doing this? I have tried echoing the values without success. Please not that I am something of an amateur with scripting.

View 6 Replies View Related

General :: Write Shell Script That Takes A File Path As Command-line Arguments?

Dec 14, 2010

How can i write a shell script that takes a file path as command-line arguments.and it should report whether the path denotes a file or a directory.

View 2 Replies View Related

Fedora :: Erroneous Write During File Extend. Write -1 Instead Of 4096

Nov 17, 2009

Ive installed Gaussian '03 on fedora Core 10, but I'm unable to run it. It aborts and i get the following error

Code:

Erroneous write during file extend. write -1 instead of 4096
Probably out of disk space.
Write error in NtrExt1

View 3 Replies View Related

General :: Write A Shell Script Which Will Simultaneously Collect OS User Information And Write In An Individual Text Files?

Feb 17, 2010

I want to write a shell script which will simultaneously collect OS user information and write in an individual text files.Can anyone tell me the syntax of the script.N.B. The user name will be mentioned in an array within the shell script.

View 8 Replies View Related

Fedora :: Write A Shell Script Which Will Mount The Data HDD On Boot?

Jun 18, 2011

I using fedora 14 and two HDD one for O.S and other for data. I manually mount the data HDD each time I put on my PC I want to write a Shell Script which will mount the data HDD on boot.

View 4 Replies View Related

General :: Write A Shell Script Instead Of Shell Function?

Apr 27, 2011

I would like know when it is necessary or advisable to write a shell script instead of shell function ?

View 3 Replies View Related

Fedora :: Cannot Write A File ?

Jul 24, 2009

I have a PHP script that's attempting to open a file for writing, but I am getting an error message:

Is this a php.ini setting, or some redhat setting?

View 1 Replies View Related

General :: How To Write Own Shell

May 26, 2011

how to write own shell in linux?i want to know procedure of shell programming.

View 5 Replies View Related

Programming :: How To Write A Toy Shell

Mar 24, 2011

I'm trying to write a toy linux shell. For starters this is what I'm trying to do:

1. Start a new process with fork.

2. Execute a program in the new process with execl().

3. Redirect the output from the new process from STDOUT to another file descriptor, using dup2(2).

4. In the parent process, read the output from the child process and write it to the screen.

Creating a new process and executing a program in it is no problems, the problem is that I can't seem to capture the output from it in the parent process.

Code:

//digenv
//C++arl 2011-03-24
#include <stdio.h>
#include <sys/types.h>

[code]...

View 14 Replies View Related

Red Hat / Fedora :: Can't Create/write To File '/tmp/ On CentOs

Jul 3, 2011

I have a huge issue on this error on mysql. Can't create/write to file '/tmp/#sql the full error message is Can't create/write to file '/tmp/#sql_4761_0.MYI' (Errcode: 30)

View 9 Replies View Related

General :: How To Write Korn Shell

Oct 14, 2010

I am new and start learning how to write korn shell, can you someone please translate the below command to common English? code...

View 1 Replies View Related

General :: Write A Shell Script?

Dec 11, 2010

write a shell script that allows only user 1 and user 2 to execute a program and only from terminal 01 and terminal 02

View 4 Replies View Related

Programming :: How To Write Own Shell In Unix

Sep 16, 2010

I wish to create my own shell for my operating systems project in college...

My professor has asked me to make sure that my shell can execute at least 30 or 40 commands... I have around a month's time

I have seen endless source codes in the net, I'm not able to understand any of it

How do i get about doing it?

View 2 Replies View Related

Ubuntu :: Write A Shell Script To Add Job To Cron?

Apr 1, 2011

I write a shell script below to add a job to cron.

#!/bin/sh
touch date.cron
echo '*/3 * * * * /usr/sbin/ntpdate 192.168.2.3' >date.cron

[code]....

View 4 Replies View Related

Programming :: Write A Function In A Shell Script?

Sep 22, 2010

I need a help regarding writing a function in a shell, what exactly a function does!!

View 3 Replies View Related

General :: Write A Shell Script Contains Python One?

Oct 22, 2010

I want to write a shell script contains python one. So,the result of python one is flv file. I want the path of this is copied into a enviroment variable that i have to pass as a flag argument of another program (to convert into mp3). To individuate the result of python script I thought to use (in PWD)

Code:
ls | grep -E '^.*mp3$'
But my question is: How can I copy this result into enviroment variable?

View 4 Replies View Related

Ubuntu :: Unable To Write A Shell Script To Vi

Nov 2, 2009

unable to write a shell script to vi

View 1 Replies View Related

Fedora :: Write A Bash Script That Will Create A New Text File?

Oct 22, 2009

trying to learn how to write a bash script that will create a new text file named jimbola in my home directory. The file will need to be able to have the first and last name of Jim Bola included in it.

View 4 Replies View Related

Ubuntu :: Write A Shell Script To Run The Configuration Of Vim Editor?

Apr 12, 2010

I have a question, tried to search on the Internet but it is hopeless. I want to write a shell script(bashShell) that will run commands of configuration for vim editor.For example: in the script, it will run ":let", ":set", ":highlight" to configure for vim editor. In addition to, when I searched a pattern and wrote it to file,ed vi to open it automatically. But, I couldn't highlight a word(that is the pattern I'm searching) in vim automatically

View 3 Replies View Related

Ubuntu :: How To Write Shell Script To Change Resolution

Aug 6, 2010

Writing a Shell script which changes my X11.org config to 800x600 from any other resolution .

View 1 Replies View Related

Programming :: Write Shell Script To Ssh Into A Remote Computer And Run That?

Jun 26, 2010

How do i write a shell script to ssh into a remote server with password and run a script in it?

View 2 Replies View Related

Ubuntu :: Write Shell Script To Change Resolution?

Sep 23, 2010

Canceled a sys backup in progress now my Waste bin is at max and must be emptied.However OpenSuse 11.3 contradicts itself by claiming there is 0 in the waste bin? Perhaps there is a Bash command that would solve the problem

View 8 Replies View Related

General :: Write Either PYTHON Or Bash Shell Scripting?

Jun 4, 2010

I do not know how to write either PYTHON or Bash Shell Scripting. I am to learn one for Linux Administration purpose. Which one will you recommend for a Linux Admin/Eng environment?

View 4 Replies View Related

General :: Write A Shell Script That Will Delete All The .dat Files?

Apr 21, 2011

i have to write a shell script that will delete all the .dat files in /var/oracle/etl/incoming which the created date of the file is 7 days before the currrent date.

View 8 Replies View Related







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