06-07-2011
Quote:
Originally Posted by
pankaj80
Can anyone help me here..
I am new in learning unix and finding some difficulty in preparing a small shell script. I want script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like files having names ZEB*). Then script will find all those files based on matching criteria and append the extension .sort to the sorted version of the file whilst retaining the original version of the file. Script should not sort files in sub-directories, only the top level directory it is run from.
This piece of code line is working for me but it does sort all the files present in that path/location.
find * -prune -type f |grep -v .sort| while read file
do
sort "$file" > "$file".sort
done
I want some use friendly shell script which ask user to enter the path location and enter the file name and work only on those files enter by user as input.
If you have new question, please post it in a separate thread.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I want to list only the file names which do not contain a specific keyword or search string.
OS: Solaris
Also is there any way ; through the same script I can save the output of search to a CSV (comma seperated) so that the file can be used for inventory purpose.
Any assistance will... (5 Replies)
Discussion started by: sujoy101
5 Replies
2. Shell Programming and Scripting
Hi,
i am pretty new to Unix environment .....
Can i get some help from any of you guyz on writing Unix script.
my requirement is like reading a csv file, finding a specific pattern in the lines and repalce the string with new string and write it to another file.
My file is file ABC123.dat... (3 Replies)
Discussion started by: prashant_jsw
3 Replies
3. Shell Programming and Scripting
I have the following:
HH:MM:SS
I want to use either % or # sign to remove :SS can somebody please provide me an example. I know how to do this in awk, but awk is too much
overhead for something this simple since I will be doing this in a loop a lot of times.
Thanks in advance to all... (2 Replies)
Discussion started by: BeefStu
2 Replies
4. Shell Programming and Scripting
Hi Frnds...
I have an input file name.txt and another file named as source.. name.txt is having only one column and source is having around 25 columns...i need to read from name.txt line by line and search it in source file and then save the result in results file..
I have a rough idea about the... (15 Replies)
Discussion started by: ektubbe
15 Replies
5. Shell Programming and Scripting
I have a LOG file which looks like this
Import started at: Mon Jul 23 02:13:01 EDT 2012
Initialization completed in 2.146 seconds.
--------------------------------------------------------------------------------
--
Import summary for Import item: PolicyInformation... (8 Replies)
Discussion started by: biztank
8 Replies
6. Shell Programming and Scripting
Gents,
Matching columns 1-19 in file1 and 20-38 in file 2, I would like to extract the data in the same order of file2.
file1
X 7494 11511 44149.00 48617.002 1 4321 44148.00 48198.00 49060.001
X 7494 11511 44149.00 48617.002 433 8641 44160.00 48198.00 49060.001 ... (10 Replies)
Discussion started by: jiam912
10 Replies
7. UNIX for Beginners Questions & Answers
hi I made this simple script to extract data and pretty much is a list and would like to extract data of two words separated by commas and I would like to make a new text file that would list these extracted data into a list and each in a new line.
Example that worked for me with text file... (5 Replies)
Discussion started by: dandaryll
5 Replies
8. Shell Programming and Scripting
HI ,
I WANT TO RETRIVE IN BETWEEN DATA FROM PARENTHESIS AND I AM GETTING ERRORS WHILE RUN THE AWK.I HAVE 2 FILES AND WANT TO PROCESS 1ST FILE PATTERN TO 2ND FILE AND WRITES INTO OUTPUT FILE.THIS TIME I AM PUTTING WHERE EXACTLY I AM GETTING ERRORS.SO PLEASE HELP.
PATTERN_FILE.TXT
--------------... (1 Reply)
Discussion started by: andrew_11
1 Replies
9. Shell Programming and Scripting
I have config file like this:
server_name xx opt1 opt2 opt3
suboptions1
#suboptions - disabled
suboptions2 pattern
suboptions3
server_name yy opt1 opt2 opt3
suboptions1 pattern
#suboptions - disabled
suboptions2
So basically I want to extract the server... (1 Reply)
Discussion started by: nemesis911
1 Replies
10. Shell Programming and Scripting
We have the data looks like below in a log file.
I want to generat files based on the string between two hash(#) symbol like below
Source:
#ext1#test1.tale2 drop
#ext1#test11.tale21 drop
#ext1#test123.tale21 drop
#ext2#test1.tale21 drop
#ext2#test12.tale21 drop
#ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies
LEARN ABOUT LINUX
wrap-and-sort
WRAP-AND-SORT(1) General Commands Manual WRAP-AND-SORT(1)
NAME
wrap-and-sort - wrap long lines and sort items in Debian packaging files
SYNOPSIS
wrap-and-sort [options]
DESCRIPTION
wrap-and-sort wraps the package lists in Debian control files. By default the lists will only split into multiple lines if the entries are
longer than 80 characters. wrap-and-sort sorts the package lists in Debian control files and all .install files. Beside that wrap-and-sort
removes trailing spaces in these files.
This script should be run in the root of a Debian package tree. It searches for control, control.in, copyright, copyright.in, install, and
*.install in the debian directory.
OPTIONS
-h, --help
Show this help message and exit.
-a, --wrap-always
Wrap all package lists in the Debian control file even if the entries are shorter than 80 characters and could fit in one line line.
-s, --short-indent
Only indent wrapped lines by one space (default is in-line with the field name).
-b, --sort-binary-packages
Sort binary package paragraphs by name.
-k, --keep-first
When sorting binary package paragraphs, leave the first one at the top. Unqualified debhelper(7) configuration files are applied to
the first package.
-n, --no-cleanup
Do not remove trailing whitespaces.
-d path, --debian-directory=path
Location of the debian directory (default: ./debian).
-f file, --file=file
Wrap and sort only the specified file. You can specify this parameter multiple times. All supported files will be processed if no
files are specified.
-v, --verbose
Print all files that are touched.
AUTHORS
wrap-and-sort and this manpage have been written by Benjamin Drung <bdrung@debian.org>.
Both are released under the ISC license.
DEBIAN Debian Utilities WRAP-AND-SORT(1)