Need Help about text files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need Help about text files
# 1  
Old 05-13-2011
Need Help about text files

Hello everyone,

I'm new in Unix, I would like to ask about on how to make this thing

for example;
I have a filename save_sample.txt
this save_sample.txt has a content like this;

Code:
USER | DESCRIPTION | DEFAULT FOLDER |
Me | I am only the authorized here | \home\me |
You | Your just a guest | \home\you |

and what I want to do is to remove the " | " then save each user to user.txt, the description to desc.txt and each default folder to def_dir.txt.

Is there any shell script to make this happen...
(Sorry for my english grammar...I'm not totally good in english)
Hope you get my point here.

Last edited by joeyg; 05-13-2011 at 03:23 PM.. Reason: Please use CodeTags around programs scripts and data examples
# 2  
Old 05-13-2011
To clarify

You want the first column to user.txt
the 2nd column to desc.txt
and 3rd column to def_dir.txt

Have you looked at:
Code:
cut -d"| -f1

to cut all data from the first field
This User Gave Thanks to joeyg For This Post:
# 3  
Old 05-13-2011
Code:
awk -F\| 'NF>2{u="user.txt";d="desc.txt";f="def_dir.txt";print $1 >> u;print $2 >>d;print $3 >> f}' infile

use nawk or /usr/xpg4/bin/awk if on SunOS /Solaris
This User Gave Thanks to ctsgnb For This Post:
# 4  
Old 05-13-2011
Indeed!

Yes Sir that's right...

I'll check this cut command...btw

do you know how to use this cut command and explain how it works?

Thanks
# 5  
Old 05-13-2011
The following command should bring you some info about how to use the cut command:

Code:
man cut

# 6  
Old 05-14-2011
Quote:
Have you looked at:

cut -d"| -f1

Surely:
Code:
cut -d\| -f1

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read text between regexps and write into files based on a field in the text

Hi, I have a huge file that has data something like shown below: huge_file.txt start regexp Name=Name1 Title=Analyst Address=Address1 Department=Finance end regexp some text some text start regexp Name=Name2 Title=Controller Address=Address2 Department=Finance end regexp (7 Replies)
Discussion started by: r3d3
7 Replies

2. Shell Programming and Scripting

How to add a text at the beginning of a text files in a folder?

how to add a text ( surya) at the beginning of a text files (so many) in folder text file: 111111 555555 666666 result: surya 111111 555555 666666 (3 Replies)
Discussion started by: suryanarayana
3 Replies

3. Shell Programming and Scripting

Read n lines from a text files getting n from within the text file

I dont even have a sample script cause I dont know where to start from. My data lookes like this > sat#16 #data: 15 site:UNZA baseline: 205.9151 0.008 -165.2465 35.8109 40.6685 21.9148 121.1446 26.4629 -18.4976 33.8722 0.017 -165.2243 48.2201 40.6908 ... (8 Replies)
Discussion started by: malandisa
8 Replies

4. Shell Programming and Scripting

Split a text file into multiple text files?

I have a text file with entries like 1186 5556 90844 7873 7722 12 7890.6 78.52 6679 3455 9867 1127 5642 ..N so many records like this. I want to split this file into multiple files like cluster1.txt, cluster2.txt, cluster3.txt, ..... clusterN.txt. (4 Replies)
Discussion started by: sammy777
4 Replies

5. UNIX for Dummies Questions & Answers

Changing text in multiple files, but with different text for each file

Hello, I have a situation where I want to change a line of text in multiple files, but the problem is that I want to change the text to something unique for each file. For example, let's say I have five files named bob.txt, joe.txt, john.txt, tom.txt, and zach.txt. Each of these files has a... (5 Replies)
Discussion started by: Scatterbrain26
5 Replies

6. Shell Programming and Scripting

Script to create a text file whose content is the text of another files

Hello everyone, I work under Ubuntu 11.10 (c-shell) I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment. I will show you an example: - On the one hand, there is a directory $DIRMAIL where there are... (1 Reply)
Discussion started by: tenteyu
1 Replies

7. Shell Programming and Scripting

Extracting/condensing text from multiple files to multiples files

Hi Everyone, I'm really new to all this so I'm really hoping someone can help. I have a directory with ~1000 lists from which I want to extract lines from and write to new files. For simplicity lets say they are shopping lists and I want to write out the lines corresponding to apples to a new... (2 Replies)
Discussion started by: born2phase
2 Replies

8. Shell Programming and Scripting

Find and add/replace text in text files

Hi. I would like to have experts help on below action. I have text files in which page nubmers exists in form like PAGE : 1 PAGE : 2 PAGE : 3 and so on there is other text too. I would like to know is it possible to check the last occurance of Page... (6 Replies)
Discussion started by: lodhi1978
6 Replies

9. UNIX for Dummies Questions & Answers

inserting a text after a certain word in text files

I need insert a text file content in other text file after certain word like insert content of tagfav.txt in all my html files after the <head> tag. Anyone can help me? (2 Replies)
Discussion started by: ItaloAG
2 Replies

10. UNIX for Dummies Questions & Answers

grep multiple text files in folder into 1 text file?

How do I use the grep command to take mutiple text files in a folder and make one huge text file out of them. I'm using Mac OS X and can not find a text tool that does it so I figured I'd resort to the BSD Unix CLI for a solution... there are 5,300 files that I want to write to one huge file so... (7 Replies)
Discussion started by: coppertone
7 Replies
Login or Register to Ask a Question