@@ -126,53 +126,44 @@ file.search(){
126
126
grep " ${1} " " ${2} " ;
127
127
}
128
128
129
- # file.search.int (str,file) -> pos
129
+ # file.search.pos (str,file) -> pos
130
130
# Search given text in file & return you position (eg: 1,2).
131
131
# Args:
132
132
# str (str) > takes string to search.
133
133
# file (str) > takes file path.
134
- file.search.int (){
134
+ file.search.pos (){
135
135
# return final result.
136
136
grep -n " ${1} " " ${2} " | cut -d: -f1 | head -n 1;
137
137
}
138
138
139
- # path.dirArray(dir) -> STRIP.
139
+ # path.dirArray(dir,*options ) -> STRIP.
140
140
# Gives you array of files in given directory.
141
141
# Args:
142
142
# 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.
143
145
path.dirArray (){
144
146
# taking directory arg from user.
145
- local ARGDir=" ${1} " ;
147
+ local ARGDir=${1} && shift ;
146
148
# array list file location.
147
149
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.
153
165
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.
176
167
rm " ${UriFile} " &&
177
168
# return function.
178
169
return 0;
0 commit comments