Hange display format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Hange display format
# 1  
Old 06-01-2015
Hange display format

I have a file , the file content will be modified regularly , its structure as below, the lines are begins with "A" and "B" .

#vi file1
Code:
 
this is testing file 
A  aaaaa
B  bbbbb
A  ccccc 
B  ddddd
A  eeeee 
B  fffff 
A  ggggg 
B  hhhhh

I would like to have a script to use the information in file1 to generate another file , so that when run the script , it will generate another file as below format , would advsie what can I do ? thanks

#vi file2
Code:
my_stringbbbbb aaaaa
my_stringddddd ccccc
my_stringfffff eeeee
my_stringhhhhh ggggg

# 2  
Old 06-01-2015
Is this a homework assignment?

Is my_string a constant, or is it a parameter to your script?

What have you tried to solved this problem?

Are the blank line and the this is a testing file in file1? Are the A and B lines always in that order? Are there ever other lines between the A and B lines?
# 3  
Old 06-01-2015
thanks for your help

Is this a homework assignment? ==> this is not homework assignment .
Is my_string a constant, or is it a parameter to your script? ==> my_string is a constant
What have you tried to solved this problem? ==> sorry , I am new to script writing . I tried read something but still not find any idea.

Are the blank line and the this is a testing file in file1 ? ==> in file1 , there are blank line and have other line not begins with "A" or "B" .
Are the A and B lines always in that order? ==> yes , A then B
Are there ever other lines between the A and B lines? ==> No other lines.


Instead of generating the file2 after each time run the script , is it possible to append the new lines to file2 ? for example , if there is the following new lines in file1 .

Code:
A  iiiii
B  jjjjj

then append the following new line to file2 rather than re-generate file2 ?
Code:
 
my_stringjjjjj iiiii

# 4  
Old 06-01-2015
In the 27 threads that you have started, you used to show that you were putting some effort into solving the problems that you raised. Lately, you do not show any effort on your own. We are happy to help you learn how to use the tools provided by UNIX and Linux systems, but we are not here to do your work for you and we are not here to act as your unpaid programming staff.

There are many examples of awk scripts in these forums that solve similar problems. Please show us what you have tried or, at least, tell us what research you have done and where you are stuck.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Display time in 12 hr format

Write a script named time that displays the time in standard 12-hour format, rather than 24-hour format. Allow the user to give a -m option to get 24-hour format. For example: > date Sun Feb 10 10:56:50 CST 2008 > time 10:56 AM > date Sun Feb 10 21:57:07 CST 2008 > time 9:57 PM >... (0 Replies)
Discussion started by: satish24
0 Replies

2. UNIX for Beginners Questions & Answers

Hour display format

Hello Sir/Madam, I'm using Putty utility to run a shell script. I found HOUR display in two positions in UNIX. Is it possible to display in four positions? File name example: my file name is: HourlyData_20160708_1400.txt I'm in the process of comparing current date and time with the file... (15 Replies)
Discussion started by: V1l1h1
15 Replies

3. Homework & Coursework Questions

How to display in column format?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I would like to know how to display my output to this format below: 5000 Bash 300 zsh 0 sh ... (4 Replies)
Discussion started by: scopiop
4 Replies

4. Shell Programming and Scripting

Changing display format

Hi, My file cat a.txt Sat Nov 27 00:02:00 2010 00:02:00 Usr 27: Login by edi on batch. (452) 00:02:09 Usr 27: Logout by on batch. (453) 00:02:09 Usr 27: Login by edi on batch. (452) 00:02:22 Usr 27: Logout by on batch. (453) 00:02:22 Usr 27: Login by edi on batch.... (3 Replies)
Discussion started by: ganeshanbu
3 Replies

5. UNIX for Dummies Questions & Answers

Date format Display Help

I have tried various arguments to get the date display as "Mar 10". I have tried date +"%c" -------> Wed Mar 10 11:51:21 EST 2010 date +"%b%d%Y_%H%M%S" --------> Mar102010_115121 date +"%b%d" -------> Mar10 date +"%t%b%e" ... (3 Replies)
Discussion started by: moveaix
3 Replies

6. UNIX for Advanced & Expert Users

Need to display complete format of ps

Hi All, For one of my script I need to get the complete format of PS as result. Actually in our application, we have to execute some program to get the data for batch files. Now there is some java script is running on unix for this which is not identifiable. I want to know how to... (2 Replies)
Discussion started by: nishank.jain
2 Replies

7. UNIX for Dummies Questions & Answers

Date Display Format

Hello People, How can I display the date in a continuous format along with the time as below : 20091001_154547 i.e yyyymmdd_hhmmss format. Thanks. (3 Replies)
Discussion started by: sushant172
3 Replies

8. UNIX for Advanced & Expert Users

ls -l timestamp display format

The time stamp format using "ls -l" is either mmm dd hh:mm or mmm dd yyyy. For later case, how can I know the hh:mm as well. Thanks. (3 Replies)
Discussion started by: pok.fung
3 Replies

9. Shell Programming and Scripting

ls command format display

Hi I have 3 files $ ls -l -rw-r--r-- 1 osbadmin osbadmin 427701 Apr 22 12:06 SANITY_TEST -rw-r--r-- 1 osbadmin osbadmin 427701 Apr 22 12:06 Success 123333 -rw-r--r-- 1 osbadmin osbadmin 427701 Apr 22 12:06 Success 123333 (1) I need to see this "SANITY_TEST" "Success 123333" "Success... (6 Replies)
Discussion started by: mnmonu
6 Replies

10. UNIX for Dummies Questions & Answers

Changing display and format of file

I have an input file which looks like this: 601 a 602 a 603 a 601 b 610 c 615 c 603 d 601 d 612 d I need the utput to look like this 601 a 602 603 602 a 601 603 603 a 601 602 601 b 610 c 615 615 c 610 603 d 601 612 (1 Reply)
Discussion started by: wahi80
1 Replies
Login or Register to Ask a Question