Need a command to remove the last word in the first line of a file


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Need a command to remove the last word in the first line of a file
# 8  
Old 09-04-2019
Depending of the purpose, if you are in a shell script and need to do this, you might:-

Code:
while read line
do
   cut_line="${line% *}"                        # Note that the space is the literal space in the input line
   echo "This is the value of \$cut_line \"${cut_line}\""
done < op.txt

Of course, you could do other things within the loop should you choose.



I hope that this helps,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash - sed - Remove first word from line which can begin eventually with blank

hello. How to remove first word from line. The line may or may not start with blank. NEW_PARAM1=$(magic-command " -t --protocol=TCP -P 12345-u root -h localhost ") NEW_PARAM2=$(magic-command "-t --protocol=TCP -P 12345 -u root -h localhost ") I want NEW_PARAM1 equal to NEW_PARAM2 equal ... (2 Replies)
Discussion started by: jcdole
2 Replies

2. Shell Programming and Scripting

Find word in a line and output in which line the word occurs / no. of times it occurred

I have a file: file.txt, which contains the following data in it. This is a file, my name is Karl, what is this process, karl is karl junior, file is a test file, file's name is file.txt My name is not Karl, my name is Karl Joey What is your name? Do you know your name and... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

3. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

4. Shell Programming and Scripting

sed command to remove a word from string

Hello All, I am running a command find . -name amp.cfg | cut -c 3- which gives me output something like below rel/prod/amp.cfg rel/fld/amp.cfg deb/detail/amp.cfg deb/err/amp.cfg I want to remove trailing "/amp.cfg" so that i should get output something like... (7 Replies)
Discussion started by: anand.shah
7 Replies

5. Shell Programming and Scripting

How to remove all words from a matching word in a line?

Hi Guys, :p I have a file like this: 2010-04-25 00:00:30,095 INFO - ]- start process U100M4 2010-04-25 00:00:30,096 DEBUG - ] -- call EJB 2010-04-25 00:00:30,709 INFO - - end processU100M4 2010-04-25 00:00:30,710 DEBUG - got message=Sorry I want to out put format. 2010-04-25... (5 Replies)
Discussion started by: ooilinlove
5 Replies

6. Shell Programming and Scripting

How to remove all words starting from a matching word in a line

Hi Guys, I have a file like this: wwwe 1 ioie ewew yyy uuu 88 erehrlk 4 ihoiwhe lkjhassad lkhsad yyy mmm 45 jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe yyy ggg 77 I want to remove everything after "yyy" and including "yyy" from each line in the file. So I want:... (2 Replies)
Discussion started by: npatwardhan
2 Replies

7. Shell Programming and Scripting

Remove particular word from file

Hi All, If my file is: Wed Sep 9 22:45:14 EDT 2009 sftp> sftp> sftp> sftp> sftp> sftp> sftp> sftp> sftp> sftp> sftp> sftp> sftp> This is log file generated from transfer... sftp> sftp> sftp> sftp> Files placed properly.... sftp> sftp> sftp> How can I remove "sftp>" word from this... (4 Replies)
Discussion started by: darshakraut
4 Replies

8. UNIX for Dummies Questions & Answers

Command to remove First and Last line from a File

I have a file from which the Header and the Trailer lines need to be removed. They are confirmed to be the first and the last lines in the file. I have tried a few commands, but not successful yet. It needs to be implemented urgently, hence any help is greatly appreciated. Raghu ----------... (1 Reply)
Discussion started by: ragz_82
1 Replies

9. UNIX for Dummies Questions & Answers

how to move word by word on command line

Hey All, On commad promt of a shell.. How can we move our cursor word by word. Like Ctrl+A takes to the starting of the command... Any shortcut like that..? Thanks pbsrinivas (1 Reply)
Discussion started by: pbsrinivas
1 Replies

10. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies
Login or Register to Ask a Question
LIPO(1) 						      General Commands Manual							   LIPO(1)

NAME
lipo - create or operate on fat files SYNOPSIS
lipo [-info] [-detailed_info] [-arch arch_type input_file] ... [ input_file] ... [-create] [-thin arch_type] [-replace arch_type file- name] ... [-remove arch_type] ... [-extract arch_type] ... [-extract_family arch_type] ... [-output output_file] [-segalign arch_type value] ... DESCRIPTION
The lipo command creates or operates on ``fat'' (multi-architecture) files. It only ever produces one output file, and never alters the input file. The operations that lipo performs are: listing the architecture types in a fat file; creating a single fat file from one or more input files; thinning out a single fat file to one specified architecture type; and extracting, replacing, and/or removing architec- tures types from the input file to create a single new fat output file. Only one option can be specified, with the exception of -arch, -output, and -segalign, which are used in combination with other options. The input_file argument is required, and only the -create option allows more than one input_file to be specified. The -output flag must be used, except with the -info and -detailed_info flags. The arch_type arguments may be any of the supported architecture names listed in the man page arch(3)exceptforVAXandMips. OPTIONS
-info Briefly list the architecture types in the input fat file (just the names of each architecture). -detailed_info Display a detailed list of the architecture types in the input fat file (all the the information in the fat header, for each archi- tecture in the file). -arch arch_type input_file Tells lipo that input_file contains the specified architecture type. The -arch arch_type specification is unnecessary if input_file is an object file, a fat file, or some other file whose architecture(s) lipo can figure out. -output output_file Specifies its argument to be the output file. -create Take the input files (or file) and create one fat output file from them. -thin arch_type Take one input file and create a thin output file with the specified arch_type. -replace arch_type file_name Take one fat input file; in the output file, replace the arch_type contents of the input file with the contents of the specified file_name. -remove arch_type Take one fat input file and remove the arch_type from that fat file, placing the result in the output file. -extract arch_type Take one fat input file and copy the arch_type from that fat file into a fat output file containing only that architecture. -extract_family arch_type Take one fat input file and copy all of the arch_types for the family that arch_type is in from that fat file into an output file containing only those architectures. The file will be thin if only one architecture is found or fat otherwise. -segalign arch_type value Set the segment alignment of the specified arch_type when creating a fat file containing that architecture. value is a hexadecimal number that must be an integral power of 2. This is only needed when lipo can't figure out the alignment of an input file (cur- rently not an object file), or when it guesses at the alignment too conservatively. The default for files unknown to lipo is 0 (2^0, or an alignment of one byte), and the default alignment for archives is 4 (2^2, or 4-byte alignment). SEE ALSO
arch(3) Apple Computer, Inc. October 23, 1997 LIPO(1)