combining cat output and cutting rows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting combining cat output and cutting rows
# 1  
Old 06-03-2011
combining cat output and cutting rows

I have a file that contain the following.
Code:
-D HTTPD_ROOT="/usr/local/apache"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

I want a shell script, so that after cat filename and apply the shell script I should get the output as follows.
Code:
/usr/local/apache/conf/httpd.conf

ie
cat filename | <shell_script>
# 2  
Old 06-03-2011
Code:
 sed -e 's/[-[A-Z_*=]//g;s/"//g'  test.txt |sed 'N;s/\n /\//'
/usr/local/apache/conf/httpd.conf

Thanks
Sha
# 3  
Old 06-03-2011
Code:
awk -F"\"" '{printf $2;getline;print "/"$2}' filename

This User Gave Thanks to pravin27 For This Post:
# 4  
Old 06-03-2011
Alternate sed..
Code:
 
sed 's/^.*=//;N;s/\n.*=/\//;s/"//g' inputfile > outfile

# 5  
Old 06-03-2011
Quote:
Originally Posted by pravin27
Code:
awk -F"\"" '{printf $2;getline;print "/"$2}' filename

Thank you very much. It worked. Now if I get this also correct, it s huge relieve,

File content
Code:
"now"you"
"can"dance"

Result should be
Code:
now you can dance

# 6  
Old 06-03-2011
Code:
awk -F"\"" '{printf $2" "$3;getline;print " $2" "$3}' filename

# 7  
Old 06-03-2011
I also got it . Thanks Smilie

Code:
sed -e 's/"//g' |  awk '{printf $1" "$2;getline;print " "$1" "$2}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cutting disk space output

Running this code df -h | head -2 | awk '{print $8}' Gives me the following output: %iused 6% What I'm trying to do is get the 6% but I'm having trouble doing this using cut -c, I think that this could be because the text is on different lines; is there a way of doing this? (8 Replies)
Discussion started by: $shell_Learner
8 Replies

2. Shell Programming and Scripting

Combining rows into columns

hi experts, I have a flat file with below contents Database1 Table1 column1 Database1 Table1 column2 Database1 Table1 column3 Database1 Table1 column4 Database1 Table2 Column1 Database1 Table2 Column2 Database2 Table1 Column1 Database2 Table1 Column2 Database2 Table1 Column3... (9 Replies)
Discussion started by: Selva_2507
9 Replies

3. Shell Programming and Scripting

Getting output from a file similar to cat output

I have a file # cat /root/llll 11 22 33 44 When I cat this file content to a variable inside a shell script and echo that shell script, it does not show up as separate lines. I need echo output similar to cat. cat /root/shell_script.sh #!/bin/bash var=`cat /root/llll` echo $var (2 Replies)
Discussion started by: anil510
2 Replies

4. Shell Programming and Scripting

Cutting rows at specific length

Hi, i have a file containing nrows and 3cols. i want to cut it in specific length and save output to individual files. 1 2 3 4 5 6 5 8 9 10 11 12 13 14 15 16 17 18 i need to cut the file say every 2 rows and save it in individual file. 01.dat contains 1 2 3 4 5 6 02.dat 7 8 9... (10 Replies)
Discussion started by: ida1215
10 Replies

5. Shell Programming and Scripting

Cutting strings from output of command

Hi, I am new to scripting and need help in cutting strings from output of a command. For exapmle in am getting the following as the out out from the command i run: Out Condition: Askajdsdfa | date: 1204 | oper: + I need to get the output as Askajdsdfa and 1204. Thanks (3 Replies)
Discussion started by: hraj1984
3 Replies

6. Shell Programming and Scripting

Combining multiple rows in single row based on certain condition using awk or sed

Hi, I'm using AIX(ksh shell). > cat temp.txt "a","b",0 "c",bc",0 "a1","b1",0 "cc","cb",1 "cc","b2",1 "bb","bc",2 I want the output as: "a","b","c","bc","a1","b1" "cc","cb","cc","b2" "bb","bc" I want to combine multiple lines into single line where third column is same. Is... (1 Reply)
Discussion started by: samuelray
1 Replies

7. Shell Programming and Scripting

Combining rows in a text file with a character limit

I have a file that contains several thousands rows. Here is an example. ^411912$ ^487267$ ^643776$ ^682249$ ^687737$ ^692328$ ^693767$ ^695483$ ^697289$ ^757411$ ^776688$ ^778953$ ^806123$ ^872262$ ^877877$ ^839837$ ^76666$ ^72018$ ^23330$ (3 Replies)
Discussion started by: justinb_155
3 Replies

8. Shell Programming and Scripting

Cutting Part of Output

Hello all I'm using bourne shell and need to figure out how to cut out a specific portion of some output. For example, my output from my command is: 12.12.52.125.in-addr.arpa name = hostname.domain.main.gov I need to get just the "hostname.domain.main.gov" part. What I'm trying... (9 Replies)
Discussion started by: lee.n.doan
9 Replies

9. Shell Programming and Scripting

Cat of rows

Hello, I'm starting from the scratch with Unix, and I was wondering if you could give me an answer for this problem... I've got a column with different names of files, something like: ./file1 ./file2 ... Now, I would like to show the content of each file. The column with the names comes... (5 Replies)
Discussion started by: kalius88
5 Replies

10. Shell Programming and Scripting

Cutting rows after a selected point

I have a log file from which I want to cut out the ten lines assoictiated to my search requirment (cust_ref #). The cust_ref number will be on te first line and the update information will be on the following ten lines (which dosen't linking data to grep on). Using a script I would like to... (4 Replies)
Discussion started by: nhatch
4 Replies
Login or Register to Ask a Question