linux script that deletes blank lines in a text file [closed] - linux

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I tried searching in here, but it's seems there is only commands that helps to delete blank lines in text file.
Is there a linux bash script that I can execute to delete blank lines in any text file I want ?

Replace file.txt with the name and path to your file and run this command in the shell:
sed -i '/^$/d' file.txt

Related

How to display files where the name starts with an 'a' and has a 'c' as third letter? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Display files in home directory starting with 'a' and third letter as 'c'.
This is what I have tried:
ls | grep '^a.c$'
But this is printing start with 'a' and ending with 'c'.
To meet your requirement, you can use
ls | grep -x a.c*
The -x option for grep means whole line match.
As for your current approach, $ stands for "end of line", so files ending with c will be printed.

How can install arm-linux-gcc-3.3.2.tar.bz2 on ubuntu [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to make cross compiler. And I commend like tar xvjf arm-linux-gcc-3.3.2.tar.bz2. But when ls /usr/local/arm there is nothing. arm directory doesn't exsist.... I dont know what to do.....
The command that you have there:
tar xvjf arm-linux-gcc-3.3.2.tar.bz2
extracts that archive within the directory you are currently in. So, if you expect things to show in /usr/local/arm ... you have to copy them there!
Thats about it - see here!

Shell script to compare file names(without extension) in a directory [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
My requirement is I will have xml and pdf files like pairs.(e.g.,file1.xml, file1.pdf and file2.xml,file2.pdf) in same folder.
I need to check for xml files which are not having pdf pair and move them to different folder.(e.g., if file3.xml doesn't have file3.pdf, I need to move it to different folder).
Please answer me the shell script to do get this functionality done.
You can remove the extension using parameter expansion:
#! /bin/bash
for file in *.xml ; do
if [[ ! -f ${file%.xml}.pdf ]] ; then
mv "$file" folder/
fi
done

Linux: copy all files using the * wildcard that contain the word file [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've worked all night on this, but haven only solved part of the problem. I am trying to copy all files using the * wildcard that contain the word file in the filename into the work directory.
try doing this :
cp *file* ./work/
cp *file* work/
Is this homework?

reading filenames from a file and moving files from one location to other in Unix [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have one file which contains filenames.
I want read those filenames from that file and move them to particular location.
awk '{old=$0;new=/path/pathsub/;system("mv \""old"\" "new)}' your_file_with_file_list
You can use a simple loop:
#!/bin/bash
while read -r filename;
do
mv "$filename" /DESTINATION/PATH/
done < input_filename

Resources