Solved

Truncate last 40 chars of every line in a file

Posted on 1998-12-02
1
240 Views
Last Modified: 2010-04-21
I am wondering if there is some function to turncate the last 40 chars of every line in a given file. And also, when I execute the system command like "system(". .profile");" in a C program, the profile is not executed.
0
Comment
Question by:bujji120198
1 Comment
 
LVL 51

Accepted Solution

by:
ahoffmann earned 30 total points
ID: 2008182
awk '{l=length($0);if(l>40){print substr($0,1,l-40)}}' file

How do you proove that .profile was not executed?
I suggest adding following to your .profile:
echo "called at `date` by $user" > /tmp.profile

Then tell us what the error is, or what does not work.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now