Sponsored Content
Top Forums Shell Programming and Scripting Help with Complex Bash Script Post 302990750 by kpkanani on Tuesday 31st of January 2017 12:47:01 PM
Old 01-31-2017
use below code which wills serve your purpose.

Code:
#!/bin/bash
BASE_DIR=/Users/karan/Practice_Shell_Scripting/Move_Invoice
SOURCE_DIR=/Users/karan/Practice_Shell_Scripting/Move_Invoice/Source_DIR
TARGET_DIR=/Users/karan/Practice_Shell_Scripting/Move_Invoice/Target_DIR

rm ${BASE_DIR}/FIle_list.txt

find ${SOURCE_DIR}/ -name "*.pdf" >> ${BASE_DIR}/FIle_list.txt

for i in `cat ${BASE_DIR}/FIle_list.txt`
do
	FILE_NAME=`basename $i`
	FOLDER_NAME=`basename $i| awk -F "_" '{print $6}'`
	echo ${FILE_NAME}
	echo ${FOLDER_NAME}
	if [ -d "${TARGET_DIR}/${FOLDER_NAME}" ]
	then
		mv $i ${TARGET_DIR}/${FOLDER_NAME}/
	else
		mkdir -p ${TARGET_DIR}/${FOLDER_NAME}
		mv $i ${TARGET_DIR}/${FOLDER_NAME}/
	fi
done


Last edited by Corona688; 01-31-2017 at 02:07 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need complex script, anyone up for a challenge?

Default shell is /usr/bin/zsh Script will be running #!/bin/bash Need to pull information from database while using other scripts already made (not by me). Ok, so i need a script pulling certain information about a customer's router interfaces. I am using a ROUTER-DNS-NAME as variable $1 I... (3 Replies)
Discussion started by: ///NNM
3 Replies

2. Shell Programming and Scripting

complex find in script

How to I put my find command string into a script. It is currently to long to be entered manually at command line. for FNAME in `find /unixsxxx/interface/x.x/xxxxxx -type f \( -name '*.KSH' -o -name '*.sh' -o -name '*.sql' -o -name '*.ksh' \) -exec grep -il xxx.xxx.xxx.xxx {} \;`; do C=`grep -c... (5 Replies)
Discussion started by: TimHortons
5 Replies

3. Shell Programming and Scripting

Complex coloring in script

My script prints lines in which the entire line may be colored, and portions may also be colored. e.g. Consider this to be one line: $red some text in red $yellow abcd $end_yellow red text 1234 $blue some text $end_blue more red text $end_red So using sed, I may based on condition 1,... (5 Replies)
Discussion started by: sentinel
5 Replies

4. Shell Programming and Scripting

Complex Script

hey... i had a big problem with my professor i have 3 simple archives in.txt -> had all timestamps of users logon (100lines) ex. 111111 222222 333333 out.txt -> had all timestamps of users logof (100lines) ex. 111113 222225 333332 commands.txt... (9 Replies)
Discussion started by: beandj
9 Replies

5. Shell Programming and Scripting

Difficult problem: Complex text file manipulation in bash script.

I don't know if this is a big issue or not, but I'm having difficulties. I apoligize for the upcoming essay :o. I'm writing a script, similar to a paint program that edits images, but in the form of ANSI block characters. The program so far is working. I managed to save the image into a file,... (14 Replies)
Discussion started by: tinman47
14 Replies

6. Shell Programming and Scripting

awk script (complex)

picked this up from another thread. echo 1st_file.csv; nawk -F, 'NR==FNR{a++;next} a{b++} END{for(i in b){if(b-1&&a!=b){print i";\t\t"b}else{print "NEW:"i";\t\t"b} } }' OFS=, 1st_file.csv *.csv | sort -r i need to use the above but with a slight modification.. 1.compare against 3 month... (25 Replies)
Discussion started by: slashbash
25 Replies

7. Shell Programming and Scripting

Complex bash/sed, variables and nested quotes

Ok, this one isn't for everybody, it's pretty tough and I've spent a good deal of time on it without figuring it out yet. Can anybody get this script to work: #!/bin/bash cq_fname="%let outputfile="/user/cq_"$1".csv";" sed "29s/.*/\"$cq_fname\"/" file1.sas >... (3 Replies)
Discussion started by: nocloud
3 Replies

8. Shell Programming and Scripting

Complex calulation in shell script

Hi , I need one help to do some complex calculation in shell script. here is what i need to do:- a=2 b=2 c=2 d=2 result=a+(b/(20*c))+(c/(10*d)) is there any thing special there so that i can group intermdiate results. Please help me if you have any idea. (4 Replies)
Discussion started by: harpal singh
4 Replies

9. Shell Programming and Scripting

Complex: bash, using ANSI-C quotes in skript

Hello, I hope someone can hep with this. I use a skript to send multiline Data to a Monitoring system. Bu I'm not able to use linebreaks or escape sequences. The skript is simple like that: #!/bin/bash var="Erste Zeile \n zweite Zeile \n Dritter Teil" zabbix_sender -c... (17 Replies)
Discussion started by: mpmichael
17 Replies

10. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies
monodoc(1)						      General Commands Manual							monodoc(1)

NAME
monodoc - GUI Mono documentation browser SYNOPSIS
monodoc [options] DESCRIPTION
monodoc is a GTK#-based browser for viewing collected API documentation for CLI libraries installed on the system RUNTIME OPTIONS
The following options are available for browsing documentation: TOPIC Start the browser at TOPIC (ex. N:System, T:System.Object, M:System.Object.Equals, and P: for properties, F: for fields, E: for events, etc.) --help Print a brief instructions on usage --about About the monodoc browser --html TOPIC Print the HTML contents of TOPIC --make-index Create the documentation index --make-search-index Create the searchable documentation index --engine Select a browser backend (Gecko, GtkHtml, WebKit, MonoWebBrowser) The following options are available for authoring documentation: --assemble Runs the doc assembler --cs-to-ecma DOCFILE ASSEMBLY OUTPUT LIBRARY-NAME Converts C# documentation to Monodoc format --edit path Edit (unassembled) documentation at path --get-sourcesdir Prints the location of monodoc sources --merge-changes CHANGE_FILE [TARGET_DIR] --normalize Format a documentation file consistently --validate Validate the XML files SEE ALSO mono(1), mdassembler(1), mdcs2ecma(1), mdnormalizer(1), mdvalidator(1), monodocs2html(1), monodocer(1) monodoc(1)
All times are GMT -4. The time now is 05:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy