02-10-2014
Read input files and merge them in given order and write them to input one param or one file
Dear Friends,
I am looking for a shell script to merge input files into one file .. here is my idea:
1st paramter would be outfile file (all input files content)
read all input files and merge them to input param 1
ex: if I pass 6 file names to the script then 1st file name as output file and merge rest of 5 files to 1st file:
cat file1 file2 file3 file4 file5 file6 > file1
i want above to be executed at end but trying to figure out how to read input params and call that cat command at end... the reason becuase input files are dynamic.. some times it could be 4 files, some times 5 and 8 are most input files... so script needs to read all input files and based on the count it needs to issue the cat command at end as per the no of input params..
any information would be greatly appriciated.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Here is an answer rather than a question that I thought I would share.
In my first attempt, I was using grep to find a list from file.1 within another file, file.2 which I then needed to paste the output from file.3 to file.1 in the same order. However, the results weren't what I wanted.
At... (2 Replies)
Discussion started by: Kelam_Magnus
2 Replies
2. Shell Programming and Scripting
Hi guys,
I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help.
I have 2 input files (example given below)
Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies
3. Shell Programming and Scripting
Hi-
I am hoping someone can give me some pointers to get me started. I have a file which contains some dn's .e.g file 1
cn=bob,cn=user,dc=com
cn=kev,cn=user,dc=com
cn=john,cn=user,dc=com
I have a second file e.g. file.template which looks something like :-
dn: <dn>
objectclass:... (5 Replies)
Discussion started by: sniper57
5 Replies
4. Shell Programming and Scripting
Hi
i am running a issue with the way i handel open file in perl
i have the following input file <File1>
D33963|BNS Default Swap|-261564.923909249|
D24484|BNS Default Swap|-53356.6868058492|
D24485|BNS Default Swap|-21180.9904679111|
D33965|BNS Default Swap|154181.478745804|... (6 Replies)
Discussion started by: kykyboss
6 Replies
5. Shell Programming and Scripting
Hello,
I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall:
I regularly need to delete files from many directories.
A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies
6. Shell Programming and Scripting
Hi,
can some one help me how to encrypt and decrypt a file.
AIM: reade user input, encrypt it and save it to file.
while decryption read the encrypted file decrypt it and save the output in some variable.
Example: consider we have Credentials.txt file with content username: password... (5 Replies)
Discussion started by: saichand1985
5 Replies
7. Shell Programming and Scripting
Hi Guys,
I need a help to creating a bash script to merging two files that containing not in order pattern into single file also within that single file I need to concatenate and manipulate the string from two files. Appreciate for any kind help given.
Thanks.
Here are the input files:... (3 Replies)
Discussion started by: jabriel
3 Replies
8. Shell Programming and Scripting
Using Linux (bash), I have two files which contain information about berries. Example:
file1.txt:
Blueberry blue 14
Raspberry red 12
Blackberry dark 4
file2.txt
Blackberry sour 4 3
Blueberry tasty 12 78
Strawberry yummy 33 88
I want to merge these two files into one. The desired... (5 Replies)
Discussion started by: Zooma
5 Replies
9. Shell Programming and Scripting
Hi,
I am working on a script, which requests users to enter input.
Ex: read -p "Please enter your email id:" email
I don't want users skipping this entry, this has to be mandatory.I dont want to proceed without input.
I can do a check if variable $email is empty and proceed if not.But, i... (7 Replies)
Discussion started by: aravindadla
7 Replies
10. Shell Programming and Scripting
Hi All
Please Help
Read input write multply output with creteria
Exemple i have file
abc 111 444
abc 111 444
def 111 444
def111 444
bbb 111 444
bbb 111 444
i would need write 3 files pos 1-3 is the Criteria
output would be file1 contains abc file2 def file3 bbb
... (3 Replies)
Discussion started by: tonyk334
3 Replies
cat(1) User Commands cat(1)
NAME
cat - concatenate and display files
SYNOPSIS
cat [-nbsuvet] [file...]
DESCRIPTION
The cat utility reads each file in sequence and writes it on the standard output. Thus:
example% cat file
prints file on your terminal, and:
example% cat file1 file2 >file3
concatenates file1 and file2, and writes the results in file3. If no input file is given, cat reads from the standard input file.
OPTIONS
The following options are supported:
-n Precede each line output with its line number.
-b Number the lines, as -n, but omit the line numbers from blank lines.
-u The output is not buffered. (The default is buffered output.)
-s cat is silent about non-existent files.
-v Non-printing characters (with the exception of tabs, new-lines and form-feeds) are printed visibly. ASCII control characters
(octal 000 - 037) are printed as ^n, where n is the corresponding ASCII character in the range octal 100 - 137 (@, A, B, C, . . .,
X, Y, Z, [, , ], ^, and _); the DEL character (octal 0177) is printed ^?. Other non-printable characters are printed as M-x,
where x is the ASCII character specified by the low-order seven bits.
When used with the -v option, the following options may be used:
-e A $ character will be printed at the end of each line (prior to the new-line).
-t Tabs will be printed as ^I's and formfeeds to be printed as ^L's.
The -e and -t options are ignored if the -v option is not specified.
OPERANDS
The following operand is supported:
file A path name of an input file. If no file is specified, the standard input is used. If file is `-', cat will read from the
standard input at that point in the sequence. cat will not close and reopen standard input when it is referenced in this
way, but will accept multiple occurrences of `-' as file.
USAGE
See largefile(5) for the description of the behavior of cat when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes).
EXAMPLES
Example 1: Concatenating a file
The following command:
example% cat myfile
writes the contents of the file myfile to standard output.
Example 2: Concatenating two files into one
The following command:
example% cat doc1 doc2 > doc.all
concatenates the files doc1 and doc2 and writes the result to doc.all.
Example 3: Concatenating two arbitrary pieces of input with a single invocation
The command:
example% cat start - middle - end > file
when standard input is a terminal, gets two arbitrary pieces of input from the terminal with a single invocation of cat. Note, however,
that if standard input is a regular file, this would be equivalent to the command:
cat start - middle /dev/null end > file
because the entire contents of the file would be consumed by cat the first time `-' was used as a file operand and an end-of-file condition
would be detected immediately when `-' was referenced the second time.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cat: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All input files were output successfully.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
touch(1), attributes(5), environ(5), largefile(5), standards(5)
NOTES
Redirecting the output of cat onto one of the files being read will cause the loss of the data originally in the file being read. For exam-
ple,
example% cat filename1 filename2 >filename1
causes the original data in filename1 to be lost.
SunOS 5.10 1 Feb 1995 cat(1)