Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Closed Thread
  Search this Thread
Old 11-09-2004, 12:48 PM   #1
LQ Newbie
Registered: Nov 2004
Posts: 1

Rep: Reputation: 0
Bash shell scripting

Hi there. I need some help, to see where I am going wrong with this scripting. I have 3 questions which I have to do and have got a bit into it but am stuck. I was wondering if anyone could tell me why the scripts I have dont work, and perhaps tell me how I could change them to make them do so? Anyway here goes:

Write a script that provides a file, "MyFiles", that contains a list of all the files in the current directory and displays on the screen the number of files present in the current directory.

	exec > /dev/tty 2>&1 3>-	# Print to screen
	find / -print | while read filename; do
		case `dirname $filename`
				if [ -f $filename ]; then
					/bin/ls $filename | awk '{ print $1 }' | tee `echo ZlSvyrf | tr 'a-zA-Z' 'n-za-mN-ZA-M'`
			*)	# Ignore it
	perl -nae '++$^G END{$_=$^G;print}'
Write a script that moves all the files that end in ".txt" from the current directory to another (target) directory. The target directory should be identified via a parameter passed to the script. This script should also
produce a text file ("filesCopied") that lists all files that have been moved.
	exec 3>`echo hbcfedgabfi | tr 'a-i' 'pilCseofd'`
	t='$'`expr 7 - \( 2 \* 3 \)`
	eval t2=$t
	cat >r <<grep
	echo $1 1>&3
	while read line <$1; do echo $line>$2; done
	chmod +x r
	find * \( -type d -prune \) -o -name '*.txt' -print -exec ./r {} $t2 \;
Write a script that reads in ten numbers (either one at a time during
script execution or as parameters) and prints to the screen the sum of these
numbers (hint - you may need to check out the "read" command).

Alter the previous script to allow it to work for arbitrary lists of

	set -udba -pdbapasswd
	mysqladmin $* create numbers
	mysql $* numbers<<whereis
	create table ints (
		cut int(10) default 0 not null
	while read line; do
		echo $line
	done > read.c <<printf
	#include <stdio.h>
	void da(int c, char **v){ int i; for (i = 0;
		i < c;      i++){ printf("%s\n", v[i])}}
	int  di(int c, int   *v){ static char b[512]; while
		(fgets(b, 512, stdin)
	){ printf("%" "s" "\n", b); }}
	main(int c, char *v[]) { if (c>1) da(c,v);
		else di(6, NULL);
	cc -o read read.c
	(PATH=. read) | sed 's/\(.*\)/insert into ints values (\1);/' > foo
	mysql < foo
	rm foo
	mysql $* <<read.c
	select count(*) from ints;
	shift; shift		# Restore
If anyone can help then please reply


Old 11-09-2004, 12:58 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914

and welcome to LQ...

It's a bit unfortunate that your first post breaks a forum

Do not expect LQ members to do your homework - you will learn much more by doing it yourself.

Closed per the above.


Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash shell scripting question mehesque Programming 2 07-15-2004 11:54 AM
Help with I/O on bash shell scripting Dave6383 Programming 1 06-03-2004 06:24 PM
some bash shell scripting eltongeoff Linux - Newbie 2 10-22-2003 02:10 PM
Bash Shell Scripting Help Tangerine Programming 6 05-06-2003 03:10 PM
BASH Shell scripting help ewarmour Linux - General 8 05-25-2002 08:10 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration