Read input write multply output with creteria


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read input write multply output with creteria
# 1  
Old 03-13-2018
Read input write multply output with creteria

Hi All

Please Help

Read input write multply output with creteria

Exemple i have file

Code:
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

Thank you

Last edited by vgersh99; 03-13-2018 at 01:37 PM.. Reason: code tags, please!
# 2  
Old 03-13-2018
Did you consider the csplit command?

EDIT: Looking at your problem a secong time, csplit might NOT be the tool of choice. Try instead
Code:
awk '{TMP = substr ($0, 1, 3); if (!(TMP in FN)) FN[TMP] = ++CNT; print TMP  > ("file" FN[TMP])}' file


Last edited by RudiC; 03-13-2018 at 07:53 PM..
# 3  
Old 03-13-2018
Thank you

it will create 3 files?
# 4  
Old 03-14-2018
It will create as many files as different criteria are present in the input file. Should these become more than ther OPEN_MAX system configuration parameter, append (>>) to the respective output files and close after each write.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh - Read input from file and output CSV i same row

Hello I have the following output and want the output to look: FROM: GigabitEthernet0/0 is up, line protocol is up 1 input errors, 0 CRC, 0 frame, 1 overrun, 0 ignored 275 output errors, 0 collisions, 3 interface resets GigabitEthernet0/1 is up, line protocol is up 0... (4 Replies)
Discussion started by: JayJay2018
4 Replies

2. Shell Programming and Scripting

awk - read from a file and write conditional output

I have a file, which has '|' as separator; I need to read each line from that file and produce output to another file. While reading, I have certain condition on few specific columns (like column3 ='good'); only those lines will be processed. (3 Replies)
Discussion started by: mady135
3 Replies

3. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: hyd1234
4 Replies

4. Shell Programming and Scripting

Read user input, Encrypt the data and write to file

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

5. Shell Programming and Scripting

shell, read table and write the value for each factor to output

Hey guyz, I have a table like this: 1 A=#;B=#;C=# 2 A=#;C=#;D=#;E=#;E=# 3 B=#;B=#;B=#;D=# # are just some numbers. I want to have the output like this: * 1 2 3 A # # NA B # NA # C # # NA D NA # # E NA # NA So basically, I wanna know in each of the rows in my input (which... (9 Replies)
Discussion started by: @man
9 Replies

6. Shell Programming and Scripting

Print output and read input on same line

How do I print output and read input on the same line in ksh? echo Hello, what is your name? read name (1 Reply)
Discussion started by: robin_simple
1 Replies

7. Shell Programming and Scripting

Read input and output redirection filename within a script

Hello everyone, My requirement is that within a script I need to construct the command line exactly that it was invoked with. For example : sh a.sh arg1 arg2 arg3 < input.txt > output.txt Now within a.sh, I construct a file which has these contents " sh a.sh arg1 arg2 arg3 < input.txt >... (8 Replies)
Discussion started by: hedonist12
8 Replies

8. Shell Programming and Scripting

Script to read input and output files and child scripts

I have a directory where i have *.sas; *.pl;*.sh and *.c scripts I need to find out what are the child scripts and input output files for each script: say I have a shell script which calls a perl script and a sas script: In my first line I want I a) the parent script name; b) the... (1 Reply)
Discussion started by: ramky79
1 Replies

9. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

10. Programming

read input-process-output

Can you help me ? I want to write a program ,which can open a input file (input.txt) and run as child process ,then write to output file (output.txt)....... char inFile="input.txt"; char outFile="output.txt"; int main(int argc, char **argv) { pid_t pid=1; int no=0; // no. of... (5 Replies)
Discussion started by: cupid1575
5 Replies
Login or Register to Ask a Question