Sponsored Content
Full Discussion: Shell Script for Beginner
Top Forums Shell Programming and Scripting Shell Script for Beginner Post 78046 by blowtorch on Thursday 14th of July 2005 09:58:45 PM
Old 07-14-2005
This is based on the understanding that you want to move files to some directory that is named as /some_destination/<first_letter_of_filename>/

Code:
#!/bin/sh

DESTINATION=/tmp
for file in *; do
        first=`echo $file | cut -c 1`
        if [ ! -d "$DESTINATION/$first" ]; then
                mkdir -p $DESTINATION/$first
        fi
        mv $file $DESTINATION/$first/
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Beginner trying to write a shell script!

Dear All, I'm trying to write a shell script that continously checks a certain folder. When a file is placed in the directory securely copies the file to another server. I've got the secure copying working, but I don't know how to contiously check a directory for a new file and then use that... (3 Replies)
Discussion started by: duncan_glover
3 Replies

2. Shell Programming and Scripting

Beginner shell script help

. ./testFile.sh url=http://ichart.finance.yahoo.com/table.csv?s= suf=&d=5&e=9&f=2009&g=d&a=1&b=4&c=1999&ignore=.csv wget $url$s1$suf; sleep 10; cat header.txt > $s1.txt; chmod 777 $s1.txt; sed '1d' table.csv?s\=$s1 >> $s1.txt; rm -Rf table* Very new at shell scripting as you can see... (3 Replies)
Discussion started by: harte
3 Replies

3. Shell Programming and Scripting

Debugging a beginner shell script...

I have been following a tutorial on bash which has proven to be very helpful. However, i am stuck with a command not found issue when asking for a y/n response from the user. Below is the part of code I believe is giving me grief... I have been trying to work through this for 3 hours now.... Please... (5 Replies)
Discussion started by: brokepunk
5 Replies

4. Shell Programming and Scripting

Shell script (beginner) need help...

Hello, I'm new to Sheel script and I need your help for a script I need to develop (for me). Indead, I have a software which log all entry from internet and save it in text file. But, the log is practically unreadable because every 256 characters jump to a new line (even if the message is... (5 Replies)
Discussion started by: acidoangel
5 Replies

5. Homework & Coursework Questions

Shell-script loops beginner

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: "Create a shell script that changes the selected word to another word in all files from selected archive. The... (1 Reply)
Discussion started by: oibanuelos
1 Replies

6. Homework & Coursework Questions

Shell Script (beginner)

1. The problem statement, all variables and given/known data: Arguments: http://farm9.staticflickr.com/8070/8212131370_8b6e8c10c5_c.jpg I am given these three arguments. $1, $2, $3 The first argument is the path to a directory. So, how would I go into the directory and compare files? I... (5 Replies)
Discussion started by: spider-man
5 Replies

7. Shell Programming and Scripting

Shell Programming (beginner help)

So guys basically I was really sick and couldn't attend the labs and lectures and I went to my lecture hoping he would say ok I will help you from the start but he just said google it. So If it's possible to make the assignment and explain more in detail why is that would be really helpfull. I can... (1 Reply)
Discussion started by: Joola94
1 Replies

8. Shell Programming and Scripting

C shell - a question of a beginner

Hi, can someone explain how this aliases work: alias m 'if ( \!:$ =~ *gz) set status = 1 && most \!:$ || gzcat \!:1 | most ' I mean, I know what it does, but I don't know how - what is \!:$ and \!:1 - how do it used the && and || - what it does with status variable? thanks (3 Replies)
Discussion started by: tzvikao
3 Replies

9. Shell Programming and Scripting

If condition shell script beginner

Hi all I have the folloing process that needs checking often: ps -ef | grep ih bscsrtx 206 15901 0 11:28:10 pts/6 0:00 fih -r4 bscsrtx 218 15901 0 11:28:27 pts/6 0:01 aih bscsrtx 29763 15901 4 11:27:16 pts/6 0:59 rdh -prih root 429 27268 0 11:30:15 pts/td ... (13 Replies)
Discussion started by: fretagi
13 Replies

10. UNIX for Beginners Questions & Answers

Beginner bash - basic shell script 'while' help...

Hi everyone, first time visitor to these forums here. Keeping a long story short I've been attempting to learn how to code in bash. I have VERY little previous experience with coding languages besides simply copying and pasting batch scripts for Windows. So, with that in mind I've followed a... (4 Replies)
Discussion started by: Meta
4 Replies
flow-rpt2rrd(1) 					      General Commands Manual						   flow-rpt2rrd(1)

NAME
flow-rpt2rrd -- Convert flow-report CSV output to RRDtool format. SYNOPSIS
flow-rpt2rrd [-nv] [-d debug_level] [-k keys] [-K keys_file] [-f fields] [-p rrd_path] [-P rrd_postfix] [-r rrd_storage] DESCRIPTION
The flow-rpt2rrd utility processes the CSV output of flow-report into RRDtool format. The aggregates for a key are each stored as a DS in RRD filename {rrd_path,"/",key,rrd_postfix,".rrd"}. By default a DS is created for flows, octets, and packets. The key must be specified, for example an ip-port report could use smtp,nntp,ssh,telnet as the keys which would create a separate RRD for each key. OPTIONS
-d debug_level Set debug level to debug_level (debugging code) -h Help. -k keys|html Comma separated list of key values. If the report has symbols then the key must be the symbol, ie smtp not 25. The totals_* lines may be used if they are enabled in the report. There is no default, keys must be specified with -k or -K. -K keys_file Load keys from keys_file. See -k. -f Comma separated list of columns to store. Each column maps to a DS in the RRD. Defaults to flows,octets,packets -n Enable symbol table lookups. For example TCP port 25 = smtp. This will result in RRD file names with the symbolic names if sym- bol lookups were not enabled in the report. -p rrd_path Set path to RRD files. Defaults to ".". -P rrd_postfix Set RRD file name postfix. Defaults to "". -r rrd_storage Set RRD storage for 5 minute, 30 minute, 2 hour, and 1 day databases. List items are : seperated. Defaults to 600:600:600:732. -v Enable verbose output. EXAMPLES
The following example shows the combined use of flow-nfilter (inline), flow-report, and flow-rpt2rrd to create an RRD depicting traffic from clmbo-r4 to AS 10796 and 6478 for 2004-11-08. rrdtool graph is then used to create a .png. #!/bin/sh cat << EOF>report.cfg include-filter nfilter.cfg stat-report CLMBO-R4-TO-INTERNET-BY-DESTINATION-AS type destination-as filter CLMBO-R4-INTERNET-OUT scale 100 output options +header,+xheader fields -duration stat-definition 5min-summaries report CLMBO-R4-TO-INTERNET-BY-DESTINATION-AS EOF cat << EOF>nfilter.cfg # ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.46 = so-0/0/0.0 filter-primitive CLMBO-R4-INTERNET type ifindex permit 46 # Match on traffic to the Internet filter-definition CLMBO-R4-INTERNET-OUT match output-interface CLMBO-R4-INTERNET EOF mkdir rrds # 5 minute flow files from flow-capture are here FLOW_DATA=/flows/clmbo-r4/2004-11-08/ # for each 5 minute flow,aggregate with flow-report then store to RRD for name in $FLOW_DATA/*; do echo working...$name flow-report -s report.cfg -S5min-summaries < $name | flow-rpt2rrd -k10796,6478 -p rrds done # first flow - 0:1:23 11/8/2004 START=1099890083 # last flow - 0:1:25 11/9/2004 END=1099976485 rrdtool graph CLMBO-R4-TO-INTERNET.png --start $START --end $END --vertical-label "Bits/Second" --title="CLMBO-R4 TO INTERNET BY AS" DEF:AS10796in=rrds/10796.rrd:octets:AVERAGE DEF:AS6478in=rrds/6478.rrd:octets:AVERAGE CDEF:b_AS10796in=AS10796in,8,* CDEF:b_AS6478in=AS6478in,8,* LINE1:b_AS10796in#FF0000:AS10796-in LINE1:b_AS6478in#555555:AS6478-in .fi BUGS
Hard coded to expect 5 minute flow file intervals. Does not properly parse flow-report time-series output. AUTHOR
Mark Fullmer maf@splintered.net SEE ALSO
flow-tools(1) flow-rpt2rrd(1)
All times are GMT -4. The time now is 09:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy