LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Closed Thread
 
Search this Thread
Old 11-09-2004, 11:48 AM   #1
Sco
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:

Quote:
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.


Code:
 #!/bin/sh
	exec > /dev/tty 2>&1 3>-	# Print to screen
	here=`pwd`
	find / -print | while read filename; do
		case `dirname $filename`
			$here/*)
				if [ -f $filename ]; then
					/bin/ls $filename | awk '{ print $1 }' | tee `echo ZlSvyrf | tr 'a-zA-Z' 'n-za-mN-ZA-M'`
				fi
				;;
			*)	# Ignore it
				;;
		esac
	done
	perl -nae '++$^G END{$_=$^G;print}'
Quote:
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.
Code:
	#!/bin/sh
	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
	grep
	chmod +x r
	find * \( -type d -prune \) -o -name '*.txt' -print -exec ./r {} $t2 \;
Quote:
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
numbers.
Code:
 

	#!/bin/sh
	set -udba -pdbapasswd
	mysqladmin $* create numbers
	mysql $* numbers<<whereis
	create table ints (
		cut int(10) default 0 not null
	);
	whereis
	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);
	printf
	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;
	read.c
	shift; shift		# Restore
If anyone can help then please reply

Thanks

Jimmy
 
Old 11-09-2004, 11:58 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Hi,

and welcome to LQ...


It's a bit unfortunate that your first post breaks a forum
rule... http://www.linuxquestions.org/rules.php


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


Closed per the above.


Cheers,
Tink
 
  


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 10:54 AM
Help with I/O on bash shell scripting Dave6383 Programming 1 06-03-2004 05:24 PM
some bash shell scripting eltongeoff Linux - Newbie 2 10-22-2003 01:10 PM
Bash Shell Scripting Help Tangerine Programming 6 05-06-2003 02:10 PM
BASH Shell scripting help ewarmour Linux - General 8 05-25-2002 07:10 AM


All times are GMT -5. The time now is 08:25 PM.

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