In the few cases where that does not apply, you may have used a Microsoft editor such as Notepad and corrupted the unix text file with Microsoft line terminators, and then transferred the file to unix using a BINARY mode ftp file transfer which unlike an ASCII mode ftp file transfer does not convert the format. Often the quickest fix is to re-transfer the file using the correct mode.
In most versions of ftp giving the source file an MSDOS-type file extension of .txt will make the conversion automatic. In unix the MSDOS-type file extensions have no special meaning but are useful for general cross-platform recognition of the contents of a file.
A unix Text File has a line terminator of a single character line-feed.
A Microsoft MSDOS-type Text File has a line terminator of two characters carriage-return then line-feed. This is a historical design error in MSDOS.
In some early versons of Apple MACOS the line terminator for text files is the single character carriage-return. These text files are best converted prior to tranfer to unix. Current versions of Apple MACOS use the unix single character line-feed for a line terminator.
To remove the carriage-return characters with the unix tr (translate) command:
Or if you system has the utilities, use dos2ux or dos2unix conversion utilities.
Last edited by methyl; 04-17-2012 at 06:46 PM..
Reason: assorted edits, including grammar and layout
These 3 Users Gave Thanks to methyl For This Post:
Good evening, Im newbie at unix specially with awk
From an scheduler program called Autosys i want to extract some data reading an inputfile that comprises jobs names, then formating the output to columns for example
1.
This is the inputfile:
$ more MapaRep.txt
ds_extra_nikira_usuarios... (18 Replies)
Hello experts,
I'm stuck with this script for three days now. Here's what i need.
I need to split a large delimited (,) file into 2 files based on the value present in the last field.
Samp: Something.csv
bca,adc,asdf,123,12C
bca,adc,asdf,123,13C
def,adc,asdf,123,12A
I need this split... (6 Replies)
Hi,
I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files.
To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Hi I am trying to execute the following awk script in unix but getting
the following error
awk: syntax error near line 1
awk: bailing out near line 1
for i in `cat search`
do
grep -i -l $i *.sas | awk -v token=$i '{print token "\t" $0}'
done
Please let me know what could be the... (4 Replies)
Hi All,
Can some body help me in this to work
#!/bin/ksh
nof=`wc -l outFile_R.out | sed -e 's/*//g' `
no_of_lines=`expr $nof - 0`
z=1
while ]
do
cat outFile_R.out | awk -v I="$z" 'NR==I { print $0 }' | read from_date to_date id
echo "executing $from_date... (2 Replies)
Hi
I have many problems with a script. I have a script that formats a text file but always prints the same error when i try to execute it
The code is that:
{
if (NF==17){
print $0
}else{
fields=NF;
all=$0;
while... (2 Replies)
Hi Experts,
I am adding a column of numbers with awk , however not getting correct output:
# awk '{sum+=$1} END {print sum}' datafile
2.15291e+06
How can I getthe output like : 2152910
Thank you..
# awk '{sum+=$1} END {print sum}' datafile
2.15079e+06 (3 Replies)
Actually I got a list of file end with *.txt
I want to use the same command apply to all the *.txt
Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics.
For example:
I got the file below:
file1.txt
file2.txt
file3.txt... (4 Replies)
Hi
I'm using cygwin and the script below works just fine under cygwin..
when i upload it on a unix server the script fails with the following errors
-awk: syntax error near line 1
-awk: bailing out near line 1
any ideas why?
thanx
awk '($2 ~ /*/) {
if ($4 < 40){
print... (3 Replies)