Programming :: Requesting Shell Script That Only Outputs Directories That Contain Subdirectories?
Jan 7, 2010
I have a directory that has about 5,000+ folders in it and I'd like to run a script that outputs any directory that contains a subdirectory.
View 4 Replies
ADVERTISEMENT
Jul 27, 2010
I'm looking to get a shell script to loop through a number of directories and subdirectories,looking for files that contain a particular substring, and renaming the file by replacing the search string with a different substring. For example if you had a directory full of folders that contained digital photos (along with various other files which would need to remain unaffected), and the intent was to remove the "DSC_" prefix from several thousand files buried within. I've whipped up a rather long-winded solution that works well for this purpose but chokes on directory names with spaces. I am reasonably sure there's a 2 or 3-liner that would accomplish this exact same task.
function investigate
{
path=$1
for file in `ls $1`
#for file in *
[code]....
View 1 Replies
View Related
Feb 16, 2010
I would like to make a one-liner, which diff's "ps aux" output before and after killing a process. So basically it should be a combination of fallowing commands:
1) diff -u
2) ps aux | awk '{print $2}'
3) kill `ps aux | grep [c]ron | awk '{print $2}'`
4) ps aux | awk '{print $2}'
How to achieve this? Something like this:
Code:
diff $( kill `ps aux | grep [c]ron | awk '{print $2}'` && ps aux | awk '{print $2}' ) $( ps aux | awk '{print $2}' )
I don't have pgrep or pkill available.
View 3 Replies
View Related
Nov 23, 2010
I am having a directory.This directory has a lot of subdirectories which contain html pages and some c source code files,Makefiles etc etc.The script I am trying to write would be executed from one directory which has all these subdirectoriesFollowing is the set of directories and files you can see
Code:
ls
delete.sh lddbus Makefile misc-progs sbull scullc scullp short simple
[code]....
View 6 Replies
View Related
Nov 6, 2010
The two shell scripts (t1prog and t2prog) are given below they are working fine. The input for the first program is 't1.det' and for second program is 't1.rnaml'. These two input files are in 'dir1' folder. I am executing the shell like 'sh t1prog > t1out' and 'sh t2prog > t2out' from this directory only. Then I am executing a java program 'java RNA'; for this, t1out and t2out are input files used in the program and I am getting the final output on screen.
The input files 't1.det' and 't1.rnaml' are in different folders with same name and with different values. Each folder specifies one gene sequence input files.
In mfold directory there are 5 directors and each directory contains these input files as shown below
cd mfold
dir1 dir2 dir3 dir4 dir5
cd dir1
t1.det t1.rnaml
[Code].....
for inputs in different directories and executing these and redirecting the final ouput after executing 'java RNA' statement to a file is needed.
View 2 Replies
View Related
Jul 11, 2011
I have one directory with 3 level sub-directories, and about houndard files under those directories. I need a shell script to rename all patern mateched directories and files.
For example: the patern is AA in the directory or file name.
View 14 Replies
View Related
Jun 7, 2010
tell me the command used to find a specific word in directories and sub-directories in linux?
View 4 Replies
View Related
Oct 27, 2010
I have been having some fun with the shell but have become a little lost. I want to be able to email (myself and others) outputs from various commands etc. Sometimes people wish to know the contents of my music library etc and it's nice to be able to ssh in and email an ls (or similar) output.
Here is what I have been doing:
Code:
ls -R /home/simon/mount/sata0/audio > /tmp/musiclist
mail -s $(date +%Y%m%d) email@domain.com < /tmp/musiclist
The date part works perfectly and I receive an email with a subject suiting my preferential YYYYMMDD format.
But what I'd like to figure out is how to get this into a single line of code, my first attempt was:
Code:
mail -s $(date +%Y%m%d) email@domain.com < $(ls -R /home/simon/mount/sata0/audio)
This generates an error:
-bash: $(ls -R /home/simon/mount/sata0/audio): ambiguous redirect
But if I simply run the code "ls -R /home/simon/mount/sata0/audio" - the output is exactly what I want.
Is what I'm trying to do even possible? I do realise that I could use something like this
Code:
ls -R /directory > /tmp/file && mail -s $(date +%Y%m%d) email@domain.com < /tmp/file
But this is still running two commands and I'd like to figure out how to be 'cleverer'.
View 2 Replies
View Related
Jun 6, 2011
I hav a shell script that outputs few variables. i want to output them in a table format. any unix commands?
The output i need is:
View 4 Replies
View Related
Aug 23, 2010
I am to rename all the files within a directory (which contains multiple subdirectories) recursively without invalid characters.
I tried the coding posted above.
find . -type f -printf '%p
' | while read file; do
oldfile=$(basename "$file")
newfile=$(echo "$oldfile" | sed 's/[^A-Za-z0-9_.]/_/g')
if [ ! "$newfile" == "$oldfile" ]; then
echo mv "$file" "${file%$oldfile}$newfile"
code....
but I get an error on both of them stating "find: bad option -printf find: [-H | -L] path-list predicate-list"
View 9 Replies
View Related
Nov 18, 2010
This question is very similar to this one except that I want to maintain the file's original subdirectories.
For example if I had
/temp/a/a.txt
/temp/a/a.jpg
/temp/a/b.txt
/temp/b/c.txt
/temp/d/d.txt
/temp/d/d.jpg
/temp/d/e.txt
/temp/f.txt
[Code]...
View 2 Replies
View Related
Aug 2, 2010
I've been able to get the right output that I need from sed, but how can I execute the string that sed actually outputs?
View 3 Replies
View Related
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
Nov 5, 2010
I would like to compare two md5sum outputs to see if the files match. in my script I have
Code:
ORG_FILE="/path/to/org/file.zip"
NEW_FILE="path/to/new/file.zip"
MD5_ORIG=$(md5sum -b "$ORG_FILE")
[code]....
How do I get just the MD5 hash and not the */.... stuff so I can compare them. i tried Code: JUST_HASH=${$MD5_ORIG:0:32} but All I get is
dir_mon_notify.sh: line 79: ${$MD5_ORIG:0:32}: bad substitution
View 1 Replies
View Related
Sep 10, 2010
Consider this PHP Script or just skip to the Output:
Code
Code:
-bash-2.05b# cat myDate.php
#!/usr/bin/php -q
<?php
[code]....
View 10 Replies
View Related
Sep 4, 2010
I have a requirement like this:Cut the characters from each line of a file with following positions: 21-24, 25-34 ,111-120.Thse fields now need to be placed in a tab delimited output file.Currently this is how I am achieving it:
#!/bin/sh
cat newsmaple.txt | cut -c 21-24 > out1.txt
cat newsmaple.txt | cut -c 25-34 >out2.txt
[code]....
View 1 Replies
View Related
Mar 10, 2011
How can I search for a string (for example, a constant) in all the (.cpp) files in the current direcotire and subdiretories.
View 4 Replies
View Related
Aug 2, 2010
I'm having trouble figuring out how to list the contents of a directory and exclude any subdirectories.
View 5 Replies
View Related
Apr 27, 2010
I need to small shell script that I can download hdf data from ftp://e4ftl01u.ecs.nasa.gov/MOLT/MOD13A2.005/first,file name.MOD13A2.A2000049.h26v03.005.2006270052117.hdf each sub folders.next I copy all files with h26v03 to local mashine.
View 1 Replies
View Related
Jun 5, 2011
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code:
if [ $# -eq 0 ] ; then
d=`pwd`
for i in * ; do
if test -d $d/$i ; then
echo "$i:"
code....
View 10 Replies
View Related
Jun 25, 2010
Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?
Example:
Code:
>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...
I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.
View 4 Replies
View Related
Feb 27, 2010
I have 8.04, and my update manager bugs me every day to pull updates for FF3, FF3.5 and XUL runner. whats up?
View 2 Replies
View Related
Oct 3, 2010
I want to checksum a Slackware 13.1 64-bit DVD before installing but do not have slackware64-13.1-install-dvd.iso. What is the output of stat --format=%s slackware64-13.1-install-dvd.iso?
View 5 Replies
View Related
Jun 30, 2009
With regards to [URL] , is there any steps in requesting, to upstream, a driver to be included in the coming versions of the kernel?
View 7 Replies
View Related
Dec 15, 2009
I've created a simple script based menu. This menu will be accessed by only a certain users via ssh.When user logs in, the menu will automatically run. (configured at user's .bash_profile).How do I force the session to close when user hits Ctrl-C or Ctrl-Break ?In a nutshell, I don't want user to have access to shell.
View 11 Replies
View Related
Jul 2, 2009
I have seemed to work out all bugs in pulseaudio except 1. When pulseaudio wakes up it stutters for a few seconds and then plays fine. I ran pulseaudio -vvv in the terminal and found that it was an underrun and got this message.
Code:
protocol-native.c: Requesting rewind due to end of underrun.
View 4 Replies
View Related
Apr 2, 2010
I'm trying to do the normal setup of sharing some dir's on my linux machine using samba, to allow a windows laptop to access them.
I've managed to get the printer shared and this is allowing to send print jobs, which come out beautifully! however the actual file shares still aren't accessible
Depending on my settings, if I have security = user then when I access from the windows machine I get a username and password box - I dont want this functionality, I want the system to access right away as it would between two windows shares.
If i change security = share then it simply lists the shares, but tells me they are all inaccessible.
I've googled and searched here, tried various different things but I just can't see why/where its asking me for the username/password combo.
Code:
From /var/log/samba/smbd :
Code:
View 5 Replies
View Related
Apr 4, 2011
I need to walk in folder recursively in C. To change the directory, I can use chdir, but how I can get the directories of a directory?
View 3 Replies
View Related
Aug 27, 2010
I use a commercial finite element code to produce animated GIF files of my calculation results. In case you are interested, the code is COMSOL Multiphysics 4.0a, running on Fedora 13 x86_64. Note that the FEA code only has the option of saving movies as animated GIF files in Linux.
These GIF files tend to be quite large, and although they are adequate for my own use on my local computer system, I wish to convert these files into other standard formats of more manageable size. These smaller files would then be easier to distribute to others or to include in presentations and reports.
I would like to ask for recommendations for either GUI-based video player/conversion applications or command line codes that could, for example, convert from animated GIF files to MPEG files. I would prefer an application that allows for multiple input/output format choices as well as conversion options for changing the playback speed, splicing out a portion of the original animation, etc.
View 2 Replies
View Related
Aug 19, 2011
On startup, I get two notifications that an application is requesting access to my default keyring. the problem is that I have no idea which applications are doing this. Is there any way to see what's making the request?
View 2 Replies
View Related