hello
A small shell scripting help..
I have a file say with 5 lines of text (text file).
At the end of everyline I need to add a comma at the end of the file.
Thanks, ST2000 (4 Replies)
Hi,
Does anyone know if its possible to add something like an end of line like c or java in unix?
dirs=/home/nosnam
var=''
for dir in $dirs
do
listDirs=`ls -d1 $dir/*`
for eachList in $listDirs
do
listRepos=`du -ks $eachList | awk '{ x+=$1 }; END { print x... (4 Replies)
Hi guys i am new to shell scripting. I wrote this script that simply searches a column value of file1 from file2.
please look at the code below:
awk '
FILENAME==ARGV { file_1_data=$0; next }
FILENAME==ARGV { file_2_data=substr($3,1,12); next }
END { ... (5 Replies)
How do I access one of the indices in array tst with the code below?
tst=sprintf("%5.2f",Car / 12)
When I scan thru the array with
for ( i in tst ) { print i,tst }
I get the output of:
vec-7 144
But when I try this in the END
print tst
It looks like it's not set.
What am... (6 Replies)
Hi,
I want to add \n as a EOF at the end of file if it does't exist in a single command. How to do this?
when I use command
echo "1\n" > a.txt
and
od -c a.txt
0000000 1 \n \n
0000003
How does it differentiate \n and eof in this case?
Regards,
Venkat (1 Reply)
Hi Folks,
Using the Vi, how can I add a numbers at the end of the line.
For eg: I have the numbers in the file as:
58.125.33
22.58.68
25.144.225
114.25.38
I need to add .0/8 at the end of all the line. So, it should be like
58.125.33.0/8
22.58.68.0/8
25.144.225.0/8
114.25.38.0/8 (6 Replies)
hi,
i have file which is having large sql query
eg :
i am executing this sql file but now i want to add ; after query on same line
i.e. i should look like
any idea how to achieve it ? (6 Replies)
How to add a comma at the end of each line in this file?30 1412
30 3352
30 5254
30 5543
30 7478
3 28
3 30
3 39
3 54
3 108
3 152
3 178
3 182
3 214
3 271
3 286
3 300
3 348
3 349
3 371 (3 Replies)
i want to add a white-space at the end of each line for my inp.file, but when i do it, the result is a new line with a white-space between each line!
my input:
2012 0811 1223 15.2 L 38.393 46.806 9.0 Teh 78 0.5 6.5LTeh 1
GAP=74 ... (5 Replies)
Seems simple but ive been searching for a good hour of so
I have a text file and would like to add a string to the end of line 5 ( as an example)
to ake tings hard the line number we have to add the text to is stored in a variable cunningly name $Line_to_append
any ideas on how this could... (2 Replies)
Discussion started by: dunryc
2 Replies
LEARN ABOUT BSD
readdir
DIRECTORY(3) Library Functions Manual DIRECTORY(3)NAME
opendir, readdir, telldir, seekdir, rewinddir, closedir - directory operations
SYNOPSIS
#include <sys/types.h>
#include <sys/dir.h>
DIR *opendir(filename)
char *filename;
struct direct *readdir(dirp)
DIR *dirp;
long telldir(dirp)
DIR *dirp;
seekdir(dirp, loc)
DIR *dirp;
long loc;
rewinddir(dirp)
DIR *dirp;
closedir(dirp)
DIR *dirp;
DESCRIPTION
Opendir opens the directory named by filename and associates a directory stream with it. Opendir returns a pointer to be used to identify
the directory stream in subsequent operations. The pointer NULL is returned if filename cannot be accessed, or if it cannot malloc(3)
enough memory to hold the whole thing.
Readdir returns a pointer to the next directory entry. It returns NULL upon reaching the end of the directory or detecting an invalid
seekdir operation.
Telldir returns the current location associated with the named directory stream.
Seekdir sets the position of the next readdir operation on the directory stream. The new position reverts to the one associated with the
directory stream when the telldir operation was performed. Values returned by telldir are good only for the lifetime of the DIR pointer
from which they are derived. If the directory is closed and then reopened, the telldir value may be invalidated due to undetected direc-
tory compaction. It is safe to use a previous telldir value immediately after a call to opendir and before any calls to readdir.
Rewinddir resets the position of the named directory stream to the beginning of the directory.
Closedir closes the named directory stream and frees the structure associated with the DIR pointer.
Sample code which searchs a directory for entry ``name'' is:
len = strlen(name);
dirp = opendir(".");
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
closedir(dirp);
return FOUND;
}
closedir(dirp);
return NOT_FOUND;
SEE ALSO open(2), close(2), read(2), lseek(2), dir(5)4.2 Berkeley Distribution September 24, 1985 DIRECTORY(3)