Print a Tab


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Print a Tab
# 1  
Old 02-18-2009
Print a Tab

Hi,

I am using a BASH shell script written on a Mac running OS X to edit kml files for Google Earth. This requires me to basically piece together parts of various files. In addition, I also must insert lines of code that I myself have created. I would like to maintain the formatting of these files when I insert my own code, which requires that I insert tab spaces. How do I do that?

After reading the forum I understand that this appears to be a complicated task. However, I have not been able to figure out how to do this. Thanks a lot for any help!

Mike
# 2  
Old 02-18-2009
without knowing more about 'lines of code that I myself have created', it's hard to say....
Code:
printf "foo\tbar"
echo 'foo bar' | awk '{printf("%s\t%s\n", $1, $2)}'
echo 'foo bar' | awk -v OFS='\t'  '{print $1, $2}'

# 3  
Old 02-18-2009
Hi vgersh99,

Thank you for your reply! Here is a better explanation of how I would like to use the tab spaces. I basically want the line of code that I insert to line up with the code above it, which will be a few tab spaces in. So if the code above is 2 tabs in I thought I would have code like this:

Code:
echo tab tab 'this line starts two tabs in'

I guess I could use:

Code:
echo ''

and just use enough
Code:
''

to equal the space created by a tab, but that seems inefficient.

Mike
# 4  
Old 02-18-2009
Quote:
Originally Posted by msb65
Hi vgersh99,

Thank you for your reply! Here is a better explanation of how I would like to use the tab spaces. I basically want the line of code that I insert to line up with the code above it, which will be a few tab spaces in. So if the code above is 2 tabs in I thought I would have code like this:

Code:
echo tab tab 'this line starts two tabs in'

How about:
Code:
printf '\t\tthis line starts two tabs in\n'

Quote:
Originally Posted by msb65
I guess I could use:

Code:
echo ''

and just use enough
Code:
''

to equal the space created by a tab, but that seems inefficient.

Mike
Sorry, I'm not following the above.....
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace a column in tab delimited file with column in other tab delimited file,based on match

Hello Everyone.. I want to replace the retail col from FileI with cstp1 col from FileP if the strpno matches in both files FileP.txt ... (2 Replies)
Discussion started by: YogeshG
2 Replies

2. UNIX for Dummies Questions & Answers

How to declare an array in UNIX and print the elements with tab delimits?

Hello, In a shell script, I want to declare an array and subsequently print the elements with tab delimits. My array has the following structure and arbitrary elements: myArray=('fgh' 'ijk' 'xyz' 'abc'); Next, I would like to print it with a '\n' at the end. Thanks for your input! ... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

3. Shell Programming and Scripting

awk - Print whole string ending with a Tab if key matched

Hi , I am looking to print the whole string from file2.txt but it is only printing 77 but not the whole matched string from File2.txt Any help is appreciated. Thanks, Script awk ' BEGIN { OFS="\t" out = "a.txt"} NR==FNR && NF {a=$0; next} function print_65_11() { if... (11 Replies)
Discussion started by: High-T
11 Replies

4. UNIX for Dummies Questions & Answers

How to create a print filter that print text & image?

Currently, I have a print filter that takes a text file, that convert it into PCL which then gets to a HP printer. This works. Now I need to embedded a image file within the text file. I'm able to convert the image file into PCL and I can cat both files together to into a single document... (1 Reply)
Discussion started by: chedlee88-1
1 Replies

5. UNIX for Dummies Questions & Answers

tab delimited file that is not tab delimited.

Hi Forum I have a tab delimited file that opens well in Openoffice calc (excel). But when I perform any operation in command line, it reads the file incorrectly. When I 'save As' the same file in office as tab delimited then it works fine. The file that I think is tab delimited is actually... (8 Replies)
Discussion started by: imlearning
8 Replies

6. UNIX for Advanced & Expert Users

[Solved] remove all print jobs from a print queue

Hello, Sometimes i need to clear all the jobs of a print queue and it is really annoying to cancel one by one. Is there a way to cancel all print jobs for a specific print queue with a single command instead of cancelling them one by one? My AIX system is 5.3 Thank you for your attention (2 Replies)
Discussion started by: omonoiatis9
2 Replies

7. Shell Programming and Scripting

Compare Tab Separated Field with AWK to all and print lines of unique fields.

Hi. I have a tab separated file that has a couple nearly identical lines. When doing: sort file | uniq > file.new It passes through the nearly identical lines because, well, they still are unique. a) I want to look only at field x for uniqueness and if the content in field x is the... (1 Reply)
Discussion started by: rocket_dog
1 Replies

8. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

9. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

10. HP-UX

Print Problem in UNIX. Need to know the option to specify the print paper size

Hi, Could any one please let me know what is the option available in UNIX to print by specifying the paper size? We are using Unix11i. I could n't see any option specified in the 'lp' command to print the report by specifying the size of the paper. It would be of great help to me, if... (1 Reply)
Discussion started by: ukarthik
1 Replies
Login or Register to Ask a Question