How to include a space or an IFS when writing to a file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to include a space or an IFS when writing to a file?
# 1  
Old 03-18-2011
How to include a space or an IFS when writing to a file?

I'm working on my little Script that writes two pieces of data at a time, with different variables, vendor and alias, to a file. I can't seem to figure out how to separate them with a space, tab, or some other kind of separator so I can read them individually from the file at a later time. Can anyone point me in the right direction. I'm using a simple echo >> to append them to the file, but it's all one word. How, for example would I include a tab as part of the writing so the Script can pick out one from the other? Right now each entry is just one word.
# 2  
Old 03-18-2011
please post a snippet of you script - our crystal balls (pun intended) are somewhat fuzzy lately!
# 3  
Old 03-24-2011
I Hope it hasn't been too long. Here are the lines that write the data to the file:

Code:
echo -n $vendor >> ~/vendorlists/$vendorfilename   echo $alias >> ~/vendorlists/$vendorfilename

It suppresses the newline character so both bits of data are on the same line, but there's no space between them so instead of getting, say

dog cat

I get

dogcat
# 4  
Old 03-24-2011
Code:
echo "${vendor} ${alias}" >> ~/vendorlists/${vendorfilename}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

2. Shell Programming and Scripting

Get file name which include the current date

Hi, I'm trying to get the name of a file that has the current date in the name. The filename is on the form A<current date>01.DC, for example A2012110501.DC I have this script so far date +%y%m%d D=$(date +%y%m%d) N=A20$D echo $N N2={$N}01.DC echo $N2 And gets the following... (12 Replies)
Discussion started by: Immelstorn
12 Replies

3. Shell Programming and Scripting

Need to include two more columns in the file using awk

Hi, I have a input file with many records as below: 1J4RR4GG0BC508200 68646 1 N M i want my output file to be like with columns included dgismdh and timestamp : Example: 1J4RR4GG0BC508200 68646 1 N M dgismdh 2012-02-21 07:22:25.98591 How to do it.can we do using awk? Pls help. (6 Replies)
Discussion started by: sonam273
6 Replies

4. Shell Programming and Scripting

How do I include the file being compared into calculation?

nawk -F, 'NR==FNR{file=FILENAME;a++;next} a{if(FILENAME~file)next;b++;} END{ for(i in a){if(a && !b){print "NEW: "i}} for(i in b){if(b)print i"\t\t"b}}' OFS=, 123.csv *.csv I need to include 123.csv into the equation for the total output currently it compares whatever is on 123.csv against... (27 Replies)
Discussion started by: llcooljatt
27 Replies

5. Shell Programming and Scripting

include file name to extracted files

I've written the script below to merge only .txt files that exist in one directory into one huge .txt file and ignore other files with other extensions. now the result is one huge .txt file with all the contents of other .txt files how can i add a File Name as a comment before each file? ... (12 Replies)
Discussion started by: miss_dodi
12 Replies

6. Solaris

Space problem writing to Solaris Folder

Hello, I've got a process failure which says it may be caused by insufficient space in the directory. Is there a way I can tell what the maximum allowable size is? I've done df -k and there are no file systems over 45% so if it is a space problem it's confined to the sub directory. (4 Replies)
Discussion started by: Grueben
4 Replies

7. Shell Programming and Scripting

how to find a job which is writing a big file and eating up space?

how to find a job which is writing a big file and eating up space? (3 Replies)
Discussion started by: rush2andy
3 Replies

8. Programming

Cannot find include file: <sqlca.h>

All, I am getting the following error License : Got the license for Sun WorkShop Compiler C SPARC continuing.. "rlnseg_test.c", line 300: cannot find include file: <sqlca.h> "rlnseg_test.c", line 417: undefined symbol: sqlca "rlnseg_test.c", line 447: undefined symbol: sqlca... (2 Replies)
Discussion started by: thana
2 Replies

9. Programming

Not able to compile Pro*c file due - give errors and points to /usr/include/.. file

I am trying to compile the pro*C file but gives errors. It says it encountered "std" while it was expecting ; , = ( $ $ORACLE_HOME/bin/proc tradewind/dataaccess/Blob.pcc Pro*C/C++: Release 10.2.0.3.0 - Production on Fri May 9 11:10:54 2008 Copyright (c) 1982, 2005, Oracle. All rights... (0 Replies)
Discussion started by: shafi2all
0 Replies

10. Shell Programming and Scripting

How to include PDF file with spaces

I am able to include a pdf file as an attachment in an email using the following: echo "" > reports elm -s "RW100 PDF Reports" me@myemail.com < reports However, if I have a filename that contains some spaces, I'm not so lucky. I've tried: echo "" > reports but no luck. I keep getting... (1 Reply)
Discussion started by: lawadm1
1 Replies
Login or Register to Ask a Question