Hi,
I'm a complete beginner at all this business so any help is appreciated.
I have a script (not written by me) which I need to modify. My problems is....
tail -1c $file
.... I understand this will return the final character of the $file variable. I need to make it return the first character of the $file variable. I've already tried first, top, front etc. but non seem to work.
And please don't ask what version of unix i'm running - all I do is boot up windows and use a program called Exceed.
I can only get head to return a set number of lines. i.e. head -n1 would return the first line. I need something to return the first character/byte etc. Is there an a -? I can use to make it output only the first character?
I understand this will return the final character of the $file variable.
Just to be clear, we are talking about returning the first or final character of a file, and does not matter if it is referenced by actual name or the filename is contained in a variable. Returning portions of what is currently held in a variable is very common, but I think not what we want here.
OK, so head -1 myfile gets you the first line. Now pipe that into a command that will cut the first column out. But if the first line is empty, this solution results in null:
Consider this bad code, edited in Windows and run via CygWin after dos2unix so be
aware of any hidden "\r" charatcers...
#!/bin/bash
n=0
stackit()
{
eval $1
if
then
exit 0
fi
n=$
echo "$n"
stackit stackit
}
stackit stackit
Run under CygWin:-
AMIGA:~> cd /tmp
AMIGA:/tmp>... (2 Replies)
Hi All
Thought it would be kind of fun to implement a stack trace for a shell script that calls functions within a sub shell. This is for bash under Linux and probably not portable -
#! /bin/bash
error_exit()
{
echo "======================="
echo $1
echo... (4 Replies)
Hi,
I am new to the linux kernel development area. I want to know what is the difference between kernel mode stack and user mode stack? Does each process has a user mode stack and a kernel mode stack?? Or Each process has a user mode stack and there is only one kernel mode stack that is shared by... (4 Replies)
Hi,
I get a problem with stack overflow on HP-UX, when running a C program.
Pid 28737 received a SIGSEGV for stack growth failure.
Possible causes: insufficient memory or swap space,
or stack size exceeded maxssiz.
The possible cause i found, was that the definition of a structure had... (0 Replies)
can anyone explain how the local variables are acessed from a stack frame of that particular function..since stacks can only push or pop values and stack pointer always points to top of the stack and the frame pointer always points to the end of the previous stack frame..how local variables are... (4 Replies)
Hi, I am writing a C program under SCO Unix. I have a memory stack problem but do not know how to go about fixing it. I have tried running INSURE but that does not detect any problems.
Essentially the problem is that the memory address shifts on return from a routine. I pass a pointer to... (3 Replies)