@@ -126,53 +126,44 @@ file.search(){
126126 grep " ${1} " " ${2} " ;
127127}
128128
129- # file.search.int (str,file) -> pos
129+ # file.search.pos (str,file) -> pos
130130# Search given text in file & return you position (eg: 1,2).
131131# Args:
132132# str (str) > takes string to search.
133133# file (str) > takes file path.
134- file.search.int (){
134+ file.search.pos (){
135135 # return final result.
136136 grep -n " ${1} " " ${2} " | cut -d: -f1 | head -n 1;
137137}
138138
139- # path.dirArray(dir) -> STRIP.
139+ # path.dirArray(dir,*options ) -> STRIP.
140140# Gives you array of files in given directory.
141141# Args:
142142# dir (str) > takes directory path.
143+ # --by-time (obj) > Optional: list will be sorted by time.
144+ # --no-extension (obj) > Optional: list have no file extensions.
143145path.dirArray (){
144146 # taking directory arg from user.
145- local ARGDir=" ${1} " ;
147+ local ARGDir=${1} && shift ;
146148 # array list file location.
147149 local UriFile=" .Uri" ;
148- # check file exist.
149- path.isdir " ${ARGDir} " &&
150- # listing files to a file.
151- ls " ${ARGDir} " > " ${UriFile} " &&
152- # reading data from array file
150+ # check directory exist.
151+ path.isdir " ${ARGDir} " && {
152+ # listing files to a file.
153+ if [[ " ${* } " == * " --by-time" * ]]; then
154+ ls -t " ${ARGDir} " > " ${UriFile} " ;
155+ shift ;
156+ else ls " ${ARGDir} " > " ${UriFile} " ;
157+ fi
158+ # no extension of requested files.
159+ if [[ " ${* } " == * " --no-extension" * ]]; then
160+ local UriChotuData=" $( sed ' s/\(.*\)\.\(.*\)/\1/' " ${UriFile} " ) " ;
161+ echo " ${UriChotuData} " > " ${UriFile} " ;
162+ fi
163+ } &&
164+ # reading data from uri file.
153165 file.readlines " ${UriFile} " &&
154- # remove that temp file.
155- rm " ${UriFile} " &&
156- # return function.
157- return 0;
158- }
159-
160- # path.dirArray.SORT_BY_TIME(dir) -> STRIP.
161- # Gives you array of files in given directory sorted by time.
162- # Args:
163- # dir (str) > takes directory path.
164- path.dirArray.SORT_BY_TIME (){
165- # taking directory arg from user.
166- local ARGDir=" ${1} " ;
167- # array list file location.
168- local UriFile=" .Uri" ;
169- # check file exist.
170- path.isdir " ${ARGDir} " &&
171- # listing files to a file.
172- ls -t " ${ARGDir} " > " ${UriFile} " &&
173- # reading data from array file
174- file.readlines " ${UriFile} " &&
175- # remove that temp file.
166+ # delete that temp file.
176167 rm " ${UriFile} " &&
177168 # return function.
178169 return 0;
0 commit comments